Jump to content

Javascript Slideshow Inconsistency

- - - - -

  • Please log in to reply
2 replies to this topic

#1
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
My Javascript is a bit rusty, but I am trying to improve on a script I borrowed. It works fine on Chrome v15., IEv8, Opera v11.61 but it is a bit buggy on Firefox v9. It can't exactly say what the problem is since it works well on the other browsers, but on ff it shows the gif image, freezes, skips the other two images then restarts at the gift.
This is the code. Any taughts?
/* Javascript slide show for top banner ads */
 var imgArray = new Array();
 var numImg = 3; 
 imgArray[0] = new Image();
 imgArray[0].src = "../image/caribbeanmap.jpg"; 
 imgArray[1] = new Image();
 imgArray[1].src = "../image/banner.png";
 imgArray[2] = new Image();
 imgArray[2].src = "../image/rotate.gif";
 
 var currImg = -1;
 
 window.onload = function start(){
     setTimeout("swapImage()",2000);  
     }
 function swapImage()
 {
     if(document.images)
     {
         var nextImg = currImg + 1;
         if(nextImg >= numImg) nextImg = 0;
         if(imgArray[nextImg] && imgArray[nextImg].complete)
         {
             var target = 0;
             if(document.images.top_ad_img) target = document.images.top_ad_img;
             if(document.all && document.getElementById("top_ad_img"))
                 target = document.getElementById("top_ad_img");  
             
             if(target)
             {
                 target.src = imgArray[nextImg].src;
                 currImg = nextImg;                 
             }
             setTimeout("swapImage()",2000);
         }
         else setTimeout("swapImage()",1000);
     }
 } 


Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#2
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I checked the firefox error messages - did not see any related to JavaScript. The script runs fine even in Konqueror on Ubuntu 11.10. :cursing:
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:

#3
fread

fread

    Programming God

  • Members
  • PipPipPipPipPipPipPip
  • 787 posts
I bumping this thread since I cant find a solution. Maybe I made need to learn JQuery afterall.
Perfection of means and confusion of ends seem to characterize our age. Albert Einstein :confused:




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users