Refresh all images with javascript? - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Image

Description

Refresh all images with javascript?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Test</title> 
   </head> 
   <body> 
      <img src=""> 
      <img src="">
       etc. //from   w ww .  j a v a  2 s  .com
      <script>
  setInterval(function() {
      var images = document.images;
      for (var i=0; i<images.length; i++) {
          images[i].src = images[i].src.replace(/\btime=[^&]*/, 'time=' + new Date().getTime());
      }
  }, 10000); // 10000 milliseconds = 10 seconds
  
      </script>  
   </body>
</html>

Related Tutorials