Posted By

raondo on 12/30/10


Tagged

javascript image rotate banner


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

maltem


Static Image Rotate on Refresh


 / Published in: JavaScript
 

random image loaded on page refresh

  1. <!--
  2. // please keep these lines on when you copy the source
  3. // made by: Nicolas - http://www.javascript-page.com
  4.  
  5. var currentdate = 0
  6. var core = 0
  7.  
  8. function StringArray (n) {
  9. this.length = n;
  10. for (var i =1; i <= n; i++) {
  11. this[i] = ' '
  12.  
  13. }
  14. }
  15.  
  16. image = new StringArray(8)
  17. image[0] = 'images/header/PA021184.JPG'
  18. image[1] = 'images/header/PA021188.JPG'
  19. image[2] = 'images/header/PA021195.JPG'
  20. image[3] = 'images/header/PA021199.JPG'
  21. image[4] = 'images/header/PA021207.JPG'
  22. image[5] = 'images/header/PA021224.JPG'
  23. image[6] = 'images/header/PA021226.JPG'
  24. image[7] = 'images/header/PA021234.JPG'
  25.  
  26.  
  27. var ran = 60/image.length
  28.  
  29. function ranimage() {
  30. currentdate = new Date()
  31. core = currentdate.getSeconds()
  32. core = Math.floor(core/ran)
  33. return(image[core])
  34. }
  35.  
  36. document.write("<img src='" +ranimage()+ "'>")
  37.  
  38. //-->
  39.  
  40. </script>
  41. <!-- <img class="frontimg" src=" +ranimage()+ " width="700" height="260" /> -->

Report this snippet  

You need to login to post a comment.