View Single Post
  #1 (permalink)  
Old March 2nd, 2010, 02:55 PM
JohnAlex1101 JohnAlex1101 is offline
Registered User
 
Join Date: Mar 2010
Location: Tampa, FL
Posts: 1
Thanks: 0
Thanked 1 Time in 1 Post
Default How to recycle an image?

In their fine book, Beginning JavaScript v4, in Chapter 10, the authors show how to go through three images. How do I close this and recycle to the beginning?
Code:
<script language=JavaScript type="text/javascript">
var currentImgNumber = 1;
var numberOfImages = 3;

function window_onload()
{
	setTimeout("switchImage()",3000);
	
}
function switchImage()
{
	currentImgNumber++;
	document.imgAdvert.src = 'AdvertImage' + currentImgNumber + '.jpg';
	if(currentImgNumber<numberOfImages)
	{
		setTimeout("switchImage()",3000);   }
		history.go(-2)
		
}
</script>

</head>

<body onload="window_onload()">
<img src="AdvertImage1.jpg" name="imgAdvert" />


</body>
</html>
Reply With Quote
The Following User Says Thank You to JohnAlex1101 For This Useful Post: