Return to Snippet

Revision: 10980
at January 20, 2009 12:26 by rwczippy


Updated Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html lang="en"> 
<head> 
<title>rotate</title> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 
<script type="text/javascript"> 

var pictureArchive= ['1.jpg','2.jpg','3.jpg','4.jpg']; 

window.onload=function() { 
 var o=document.createElement('img'); 
 o.setAttribute('id', 'image'); 
 o.setAttribute('src', pictureArchive[0]); 
 o.setAttribute('alt', ''); 
 document.body.appendChild(o); 
 rotate(pictureArchive.length); 
} 

function rotate(idx) { 
 if(idx>=pictureArchive.length) { 
  idx=0; 
 }
 document.getElementById('image').src=pictureArchive[idx++];
 timerID=setTimeout('rotate('+idx+')', 4000); 
} 
</script> 
<style type="text/css"> 
</style> 
</head> 
<body> 
</body> 
</html>

Revision: 10979
at January 20, 2009 12:22 by rwczippy


Initial Code
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang="en"> <head> <title>rotate</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script type="text/javascript"> var pictureArchive= ['1.jpg','2.jpg','3.jpg','4.jpg']; window.onload=function() { var o=document.createElement('img'); o.setAttribute('id', 'image'); o.setAttribute('src', pictureArchive[0]); o.setAttribute('alt', ''); document.body.appendChild(o); rotate(pictureArchive.length); } function rotate(idx) { if(idx>=pictureArchive.length) { idx=0; } document.getElementById('image').src=pictureArchive[idx++]; timerID=setTimeout('rotate('+idx+')', 4000); } </script> <style type="text/css"> </style> </head> <body> </body> </html>

Initial URL
http://www.webdeveloper.com/forum/showthread.php?t=186968

Initial Description

                                

Initial Title
Loop Images in a HTML JavaSacript - WebDeveloper.com

Initial Tags
javascript, image, html

Initial Language
HTML