ADVANCED COMPUTER
JAVASCRIPT STUDY SHEET - HAND OUT # 2
I. EVENT NAME
- onMouseOver
<SCRIPT>
blueArrow = new Image;
blueArrow.src = bluearrow.gif;
redArrow = new Image;
redArrow.src = redarrow.gif;
</SCRIPT>
<A HREF =
webpage.html
onMouseOver=document.arrow.src =redArrow.src;
onMouseOver=document.arrow.src= blueArrow.src;
<IMG SRC = bluearrow.gif
NAME
= arrow
WIDTH
= 320
HEIGHT
= 200>>
</A>
II.
CREATING A
CYCLING BANNER.
<SCRIPT>
imgArray = new Array(4);
imgArray[0]
= new Image;
imgArray[0].src = lions.gif;
imgArray[1]
= new Image;
imgArray[1].src = lions.gif;
imgArray[2] = new Image;
imgArray[2].src = lions.gif;
imgArray[3]
= new Image;
imgArray[3].src = lions.gif;
index
= 0 ;
function
cycle( )
{
document.banner.src = imgArray[index].src;
index ++;
if (index == 4)
{
index = 0;
}
setTimeout(cycle(
), 2000);
return;
}
</SCRIPT>
<BODY onload= cycle(
);>
<IMG SRC = lions.gif
NAME = banner
WIDTH = 400
HEIGHT = 100 >