PDA

View Full Version : Background image slideshow with hyperlinks



SaraK
05-11-2009, 05:31 PM
1) Script Title: Background image slideshow

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

3) Describe problem: I used a variation of the script by jscheuer1
to put the background image slideshow inside a table. Now I want to add hyperlinks to the each of the images in the background slideshow. How do I do that? I am new to Javascript and have no clue how to do it! Any help is greatly appreciated.

Thanks!

Code I used:

<html>
<head>
<title></title>
<style>
#bslide {
/*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: center;
}
</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

//Specify background images to slide
var bgslides=new Array()
bgslides[0]="thumb2/photo1.jpg"
bgslides[1]="thumb2/photo2.jpg"
bgslides[2]="thumb2/photo3.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)
inc++
else
inc=0
document.getElementById? document.getElementById('bslide').background=processed[inc].src : document.all['bslide'].background=processed[inc].src
}

if (document.all||document.getElementById)
window.onload=new Function('setInterval("slideback()",speed)')

</script>
</head>
<body>
<table id="bslide" height="225" width="140">
<tr>
<td>&nbsp;</td>
</tr>
</table>

</body>
</html>