Results 1 to 3 of 3

Thread: Background Image Slideshow - Random?

  1. #1
    Join Date
    Oct 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Background Image Slideshow - Random?

    I was wondering how you would go about doing the Background image slideshow but instead of just cycling through the images you go through them randomly. Thanks. Background Image Slideshow

  2. #2
    Join Date
    Aug 2004
    Location
    Brighton
    Posts
    1,563
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Use this code I've made for you instead, place in BODY section as usual:

    It's important to note the instructions on this line:
    // The final number (default=3) of the next line must be equal to the number of images present.
    inc=Math.floor(Math.random() * 3)

    The code:
    Code:
    <style>
    body{
    /*Remove below line to make bgimage NOT fixed*/
    background-attachment:fixed;
    background-repeat: no-repeat;
    /*Use center center in place of 300 200 to center bg image*/
    background-position: 300 200;
    }
    </style>
    
    <script language="JavaScript1.2">
    
    //Background Image Slideshow-  Dynamic Drive (www.dynamicdrive.com)
    //For full source code, 100's more DHTML scripts, and TOS,
    //visit http://www.dynamicdrive.com
    //modified by cr3ative for random backgrounds
    
    //Specify background images to slide
    var bgslides=new Array()
    bgslides[0]="bgslide.jpg"
    bgslides[1]="bgslide2.jpg"
    bgslides[2]="bgslide3.jpg"
    
    //Specify interval between slide (in miliseconds)
    var speed=3000
    
    //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)
    
    // The final number (default=3) of the next line must be equal to the number of images present.
    inc=Math.floor(Math.random() * 3)
    
    else
    inc=0
    document.body.background=processed[inc].src
    }
    
    if (document.all||document.getElementById)
    window.onload=new Function('setInterval("slideback()",speed)')
    
    </script>
    Regards
    cr3ative
    A retired member, drop me a line through my site if you'd like to find me!
    cr3ative media | read the stickies

  3. #3
    Join Date
    Nov 2004
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi there,

    Would anyone possibly be able to take a look at randomizing the photos on this script?:

    http://www.dynamicdrive.com/dynamicindex14/image4.htm

    I would have tried it myself, however it's a bit different to the background images script, in that each thumbnail image also has a hyperlink to the main image.

    Thanks.
    Last edited by cheekymassey; 11-18-2004 at 01:25 PM.

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
  •