OneCompiler

Can you help me with this code

<!DOCTYPE html> <html> <head> <script language=JAVASCRIPT type=TEXT/JAVASCRIPT> //I'm not sure when to use '' or "" //I replaced some of the "picture.jpg" images with links to images. I'm not sure if I used the right syntax. adImages = new Array("https://i.picsum.photos/id/666/800/200.jpg", "https://i.picsum.photos/id/420/800/200.jpg", "https://i.picsum.photos/id/888/800/200.jpg"); adURL = new Array("https://google.com","https://github.com","https://stackoverflow.com"); thisAd = 0; //length of what? imgCt = adImages.length;

function rotate()
{
if (document.images)
{
thisAd++;
//Is it better practice to use "==="?
if (thisAd == imgCt)
{
thisAd = 0;
}
document.adBanner.src=adImages[thisAd];
setTimeout("rotate()", 2 * 1000);
}
}

function newLocation()
{
document.location.href = adURL[thisAd];
}
</script>

</head> //I don't understand what this is at all <body onload=rotate()> //Apparently <center> is obsolete? <center> <p><font size=4>Rotating Banner <font color=#ff0000>Assignment 6</font> Rotate Party - Udemy</font> </p> <a href="javascript:newLocation()"><IMG height=105 alt="Ad Banner" src="https://i.picsum.photos/id/666/800/200.jpg" width=610 name=adBanner></a> </center> </body> </html>

No answers yet!

2 years ago by