Happy Codings - Programming Code Examples
Html Css Web Design Sample Codes CPlusPlus Programming Sample Codes JavaScript Programming Sample Codes C Programming Sample Codes CSharp Programming Sample Codes Java Programming Sample Codes Php Programming Sample Codes Visual Basic Programming Sample Codes


JavaScript Programming

JavaScript > Code Examples

Simple Image Replacement

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
Simple Image Replacement <html> <head> <title>Replacing Images - Happy Codings :-) Simple Code Examples for JavaScript</title> <script language="JavaScript"> var ix = 0 function changeImages(milliseconds) { window.setInterval("changeImage()", milliseconds) } function changeImage() { ++ix; ix %= 6; var imageRef = document.images[0]; imageRef.src = "http://www.happycodings.com/images/"+ix+".gif"; } </script> </head> <body onload="changeImages(500)"> <p align="center"><img id="changeme" src="http://www.happycodings.com/images/HappyCodings.png"></p> </body> </html>