SEARCH
Newsletter
Subscribe to get design
tips, latest trends, free
stuff and more.
It doesn't look like an e-mail address

hosting

  Web Programming JavaScript Background Slide Show

Background Slide Show

Codelifter JavaScript Sep 23, 2005







Click to start the script.

Put this code into your page:

<html>
<head>

<style>
body{
background-repeat: no-repeat;
background-position: 200 100;
}
</style>

</head>

<script language="JavaScript">
<!--

// =======================================
// set the following variables
// =======================================

// Set speed (milliseconds)
var speed = 1000

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/slideshow_1.jpg'
Pic[1] = 'images/slideshow_2.jpg'
Pic[2] = 'images/slideshow_3.jpg'
Pic[3] = 'images/slideshow_4.jpg'
Pic[4] = 'images/slideshow_5.jpg'
Pic[5] = 'images/slideshow_6.jpg'
Pic[6] = 'images/slideshow_7.jpg'
Pic[7] = 'images/slideshow_8.jpg'
Pic[8] = 'images/slideshow_9.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}

function runBGSlideShow(){
if (document.body){
document.body.background = Pic[j];
j = j + 1
if (j > (p-1)) j=0
t = setTimeout('runBGSlideShow()', speed)
}
}

//-->
</script>

<body bgcolor=black onload="runBGSlideShow()">

<br><br>
<center><font face=arial,helvetica size=2 color=white>Sample Code 13 - Background Slideshow</font></center>

</body>
</html>

   
subscribe to newsletter