Piglet in quarantine

Hello,

Just found a little funny Winnie the Pooh picture… :)

Piglet in quarantine

Credits to the artist!

JavaScript Picture Slider

Hello,

I was coding this little Picture Slider in JavaScript for a colleague and thought: Why not just share it with everybody else?

So here it is people… It is not advanced, it is not high-tech… but it is simple!

  1. <html>
  2.  
  3. <head>
  4.     <title>Picture Slider</title>
  5.  
  6.     <script type="text/javascript">
  7.     // Setup
  8.     var imagePath = "images/"; // Path to image-folder
  9.     var images = new Array("image1.jpg", "image2.jpg", "image3.jpg", "image4.jpg", "image5.jpg"); // filenames of the images
  10.     var slideInterval = 1.5; // amount of seconds before sliding to the next image.
  11.  
  12.    // Variabels
  13.     var curImage = 0;
  14.  
  15.     // Fucntions   
  16.     function startSlide() {
  17.         setTimeout("nextSlide()", slideInterval * 1000);
  18.     }
  19.  
  20.     function nextSlide() {
  21.         var viewer = document.getElementById("imageViewer");
  22.         curImage = curImage + 1;
  23.  
  24.         if (images[curImage] == null)
  25.             curImage = 0;
  26.  
  27.         viewer.src = imagePath + images[curImage];
  28.  
  29.         setTimeout("nextSlide()", slideInterval * 1000);
  30.     }
  31.  
  32.     // Start the slider
  33.     startSlide();
  34.     </script>
  35. </head>
  36.  
  37. <body>
  38.  
  39.     <h1>Picture Slider</h1>
  40.     <br />
  41.     <img id="imageViewer" src="images/image1.jpg">
  42.  
  43. </body>
  44.  
  45. </html>

Just change the variables under the “setup” in the start of the JavaScript-code and change the src-parameter on the img-tag of the picture to show the first picture. Then the script will work.

Have fun !!

/KEF