Results 1 to 2 of 2

Thread: Background Image Slideshow- Delay before first slide/image appears

  1. #1
    Join Date
    May 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Background Image Slideshow- Delay before first slide/image appears

    Hi, I am a newbie to DD Forum but loving the javascripts. I have a problem with the Background Image Slideshow script.

    (http://www.dynamicdrive.com/dynamicindex14/bgslide.htm)

    It seems that the slide interval applies a delay on the first background image appearing. For example I set the var speed to 20000 to create a 20sec gap between slides, but the problem is when the page loads it waits 20sec before loading the first slide so I have a blank background. I want the page to have the first bg image as soon as it loads and then wait 20 secs before loading the next slide.

    If I add a bg-image into the .body selector in the css this seems to override the javascript and stop the slideshow working.

    Any ideas would be gratefully received!

    Thanks

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,807
    Thanks
    2
    Thanked 423 Times in 417 Posts

    Default

    Code:
    //Background Image Slideshow-  Dynamic Drive (www.dynamicdrive.com)
    //For full source code, 100's more DHTML scripts, and TOS,
    //visit http://www.dynamicdrive.com
    
    //Specify background images to slide
    var bgslides=new Array()
    bgslides[0]="http://www.vicsjavascripts.org.uk/StdImages/Egypt8.jpg"
    bgslides[1]="http://www.vicsjavascripts.org.uk/StdImages/Egypt9.jpg"
    bgslides[2]="http://www.vicsjavascripts.org.uk/StdImages/Egypt10.jpg"
    
    //Specify interval between slide (in miliseconds)
    var speed=5000
    
    //preload images
    var processed=new Array()
    for (i=0;i<bgslides.length;i++){
    processed[i]=new Image()
    processed[i].src=bgslides[i]
    }
    
    var inc=-1
    
    function slideback(){
    if (inc<bgslides.length-1)
    inc++
    else
    inc=0
    document.body.background=processed[inc].src
    }
    
    if (document.all||document.getElementById)
    window.onload=function(){
    slideback();
    setInterval("slideback()",speed);
     }

Bookmarks

Posting Permissions

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