Results 1 to 4 of 4
  1. #1
    Join Date
    May 2009
    Posts
    413
    Plugin Contributions
    0

    Default Removing pause at start of banner rotation...

    *BTW Not sure if this the right section to post in *

    I used a simple online Java banner rotator generator to rotate two images both with their own URL. The site is locally hosted at the moment, but I have changed the URL's for example purposes. I then simply pasted this generated code into the relevant area via Zen Cart banner manager:

    <script type="text/javascript">
    var imgs1 = new Array("/images/banners/free_box_banner.jpg","/images/banners/free_shipping_banner.jpg");
    var lnks1 = new Array("http://www.mysite.com/page.html?id=25","http://www.mysite.com/index.php?main_page=shippinginfo");
    var alt1 = new Array("All Orders Include A Free Gift Box!","Free Shipping Worldwide");
    var currentAd1 = 0;
    var imgCt1 = 2;
    function cycle1() {
    if (currentAd1 == imgCt1) {
    currentAd1 = 0;
    }
    var banner1 = document.getElementById('adBanner1');
    var link1 = document.getElementById('adLink1');
    banner1.src=imgs1[currentAd1]
    banner1.alt=alt1[currentAd1]
    document.getElementById('adLink1').href=lnks1[currentAd1]
    currentAd1++;
    }
    window.setInterval("cycle1()",5000);
    </script>
    <a href="http://www.mysite.com/page.html?id=25"" id="adLink1" target="_top">
    <img src="/images/banners/free_box_banner.jpg" id="adBanner1" border="0" width="537" height="80"></a>


    The display time between each rotation is set to 5 seconds. However on initial loading of the site their is a 10 second pause before the next banner shows up.

    Can anyone see anything in the above code which would cause this initial 10 second delay between rotation? If so how can I remove it?

    Thanks

  2. #2
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Removing pause at start of banner rotation...

    When the page loads, this script won't start until EVERYTHING on the page has completed the load. Also, as the script you have loads the banners as required, this will cause a certain lag time. So the things I would change are firstly, I would add in a pre-loader, so that all images are ready for use as soon as the script requires them. If you don't do this, then the script waits 5 seconds, and then attempts to show the image. As it's not currently in the DOM, it then loads the image, which takes an extra couple of seconds.

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

  3. #3
    Join Date
    May 2009
    Posts
    413
    Plugin Contributions
    0

    Default Re: Removing pause at start of banner rotation...

    Quote Originally Posted by Absolute View Post
    I would add in a pre-loader
    Thanks for your reply Absolute

    How what and where would I do this?

    Thanks.

  4. #4
    Join Date
    May 2005
    Location
    Bath, Somerset
    Posts
    1,053
    Plugin Contributions
    3

    Default Re: Removing pause at start of banner rotation...

    Quick google will show you examples of this Javascript. There are so many ways to do this, you would need to decide which one is best for you. Just search for "Javascript Image Preloader".

    Absolute
    Back, after a 4 year absence! Did you miss me?
    Absolute Web Solutions Ltd
    Interested in our work? Take a look at one of our sites - The Tech Store

 

 

Similar Threads

  1. Banner header rotation
    By alanlee9898 in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 31 May 2011, 05:44 AM
  2. Stop banner rotation
    By Zombie63 in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 18 Feb 2010, 10:27 PM
  3. Stop banner rotation!
    By Orchard_Direct in forum Templates, Stylesheets, Page Layout
    Replies: 5
    Last Post: 26 Jun 2008, 02:35 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg