Results 1 to 3 of 3

Thread: Background image slideshow tweaks?

  1. #1
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Background image slideshow tweaks?

    1) Script Title: Background image slideshow

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex14/bgslide.htm

    3) Describe problem:

    Hi Guys,
    I'm not necessarily having a problem with this script, it works perfectly as expected, I just wanted to change it up a bit but dont even know where to begin.

    I would like a random background on page refresh as opposed to it having go through its set sequence on a set timer.

    any help would be appreciated.

    Cheers
    Elaine

  2. #2
    Join Date
    Aug 2004
    Posts
    9,893
    Thanks
    3
    Thanked 966 Times in 954 Posts
    Blog Entries
    15

    Default

    If you mean disable auto rotation of the background image altogether and simply display a random background when the page loads, try the below code instead:

    In the HEAD section of your page:

    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>

    In the BODY section of your page, such as at the very end:


    Code:
    <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
    
    //Specify background images to slide
    var bgslides=new Array()
    bgslides[0]="bg1.jpg"
    bgslides[1]="bg2.gif"
    bgslides[1]="bg3.gif"
    
    document.body.background=bgslides[Math.floor(Math.random()*bgslides.length)]
    
    </script>
    DD Admin

  3. #3
    Join Date
    Nov 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    perfect worked like a charm! thank you very much

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
  •