Javascript examples for DOM HTML Element:Image
display one image in loop
<html> <head> <title>A test</title> </head> <body> <img src="http://x.invalid" id="myImage"> <script> var imgs = [/*www.j a v a2s .c om*/ "http://java2s.com", "https://www.google.com/images/srpr/logo11w.png", "http://www.java2s.com/style/download.png" ]; var imageIndex = 0; function tryNextImage() { var img = document.getElementById("myImage"); img.onerror = function() { imageIndex++; tryNextImage(); } img.src = imgs[imageIndex]; } tryNextImage(); </script> </body> </html>