Monday 26 September 2011

Automatic images will be changes through Javascript


 Images will automatically changes it's really amazing:-

<script type="text/javascript">

       // Set the slideshow speed (in milliseconds)
       var SlideShowSpeed = 5000;

       // Set the duration of crossfade (in seconds)

       var CrossFadeDuration = 2;
       var Picture = new Array(); // don't change this




      //***Add Your Image Here To Make Slide Show)**// Give the name of Image there//
      // Picture[1] = 'Images/img6.jpeg';
      // Picture[2] = 'Images/img3.jpeg';
       Picture[1] = 'Images/image6.jpeg';
    Picture[2] = 'Images/images.jpeg';
      Picture[3] = 'Images/images2.jpeg';
      Picture[4] = 'Images/images3.jpeg';
      Picture[5] = 'Images/images4.jpeg';


       var tss;
       var iss;
       var jss = pickRandom(Picture.length - 1);
       var pss = Picture.length - 1;
       //alert(jss);

       var preLoad = new Array();
       for (iss = 1; iss < pss + 1; iss++) {
           preLoad[iss] = new Image();
           preLoad[iss].src = Picture[iss];
       }
       function runSlideShow() {
           if (document.all) {
               document.images.LogoBox.style.filter = "blendTrans(duration=2)";
               document.images.LogoBox.style.filter = "blendTrans(duration=CrossFadeDuration)";
               document.images.LogoBox.filters.blendTrans.Apply();
           }
           document.images.LogoBox.src = preLoad[jss].src;
           //if (document.getElementById) document.getElementById("CaptionBox").innerHTML= Caption[jss];
           if (document.all) document.images.LogoBox.filters.blendTrans.Play();
           jss = jss + 1;
           if (jss > (pss)) jss = 1;
           tss = setTimeout('runSlideShow()', SlideShowSpeed);
       }
       function pickRandom(range) {
           if (Math.random)
               return (Math.round(Math.random() * range) + 1);
           else {
               return 1;
           }
       }
   </script>

Give the  name and id of images:-
<img name="LogoBox" id="LogoBox" src="images/wipro1.jpg" style="width: 892px" />

Call the fucnction on body:-
<body class="backround " onload="runSlideShow()" ></body>

No comments:

Post a Comment