Javascript - Simple Slideshow


SUBMITTED BY: Guest

DATE: Aug. 1, 2013, 1:43 p.m.

FORMAT: JavaScript

SIZE: 2.4 kB

HITS: 991

  1. <!DOCTYPE html>
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head runat="server">
  4. <title></title>
  5. <script>
  6. function rotate(imageNumber) {
  7. //Modify these variables as needed
  8. //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
  9. var myimage1 = "image1.jpg";
  10. var myimage2 = "image2.jpg";
  11. var myimage3 = "image3.jpg";
  12. var myimage4 = "image4.jpg";
  13. var link1 = 'http://link1.com';
  14. var link2 = 'http://link2.com';
  15. var link3 = 'http://link3.com';
  16. var link4 = 'http://link4.com';
  17. var time = 5000; //5000 milliseconds = 5 seconds
  18. //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  19. var image = document.getElementById('rotator');
  20. switch (imageNumber) {
  21. case 1:
  22. image.src = myimage1;
  23. image.onclick = function () { window.location = link1; };
  24. aspan.innerHTML = imageNumber;
  25. imageNumber++;
  26. break;
  27. case 2:
  28. image.src = myimage2;
  29. image.onclick = function () { window.location = link2; };
  30. aspan.innerHTML = imageNumber;
  31. imageNumber++;
  32. break;
  33. case 3:
  34. image.src = myimage3;
  35. image.onclick = function () { window.location = link3; };
  36. aspan.innerHTML = imageNumber;
  37. imageNumber++;
  38. break;
  39. case 4:
  40. image.src = myimage4;
  41. image.onclick = function () { window.location = link4; };
  42. aspan.innerHTML = imageNumber;
  43. imageNumber = 1;
  44. break;
  45. }
  46. var t = setTimeout("rotate(" + imageNumber + ")", time);
  47. }
  48. </script>
  49. </head>
  50. <body onload="rotate(1);">
  51. <div>
  52. <img src="Base.png" id="rotator" style="width:1027px;height:497px;" />
  53. </div>
  54. </body>
  55. </html>

comments powered by Disqus