|
Lesson 5 - Have Pictures Change on Your Screen
In the HEAD we have some script where we declare an Array and put some images in the array.
<Head>
<SCRIPT>
pictures = new Array (3);
pictures[0] = new Image;
pictures[0].src = "picture1.jpg";
pictures[1] = new Image;
pictures[1].src = "picture2.jpg";
pictures[2] = new Image;
pictures[2].src = "picture3.jpg";
var index = 0;
function showpicture()
{
document.sample.src = pictures[index].src;
index++;
if (index == 3)
{index = 0;}
setTimeout("showpicture()",3000);
}
</SCRIPT>
</Head>
<body onLoad = "showpicture();">
<img src ="picture1.jpg" name = "sample">
For your assignment write a web page that loads in 3 pictures and will keep flashing them on your page.
|