PDA

View Full Version : Background image slideshow tweaks?



elbabyyeh
11-16-2010, 09:25 PM
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

ddadmin
11-17-2010, 01:16 AM
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:


<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:


<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>

elbabyyeh
11-17-2010, 03:27 AM
perfect worked like a charm! thank you very much :)