PDA

View Full Version : How to add mouseover to Presentation Slideshow script



rmather
11-27-2013, 01:27 PM
1) Script Title: Presentation Slideshow

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

3) Describe problem: I love this script & want to use it, but I'd like to add a "mouseover" event that pauses the slide when the mouse hovers over it. Also, when none of the slides are linked, it does not work. Why is that? My page is http://www.anasigns.biz/vehicles.shtml. I have linked all the slides to themselves but would rather just have a mouseover event. I know very little about java script.
Thanks.

jscheuer1
11-27-2013, 04:06 PM
Use this edited version of the script:


<script language="JavaScript1.2">

//Presentational Slideshow Script- By Dynamic Drive
//For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
//This credit MUST stay intact for legal use

//Add the script where the slideshow should appear.

var slideshow_width='600px' //SET SLIDESHOW WIDTH (set to largest image's width if multiple dimensions exist)
var slideshow_height='350px' //SET SLIDESHOW HEIGHT (set to largest image's height if multiple dimensions exist)
var pause=1000 //SET PAUSE BETWEEN SLIDE (2000=2 seconds)
var slidebgcolor="fff"


var dropimages=new Array()
//SET IMAGE PATHS. Extend or contract array as needed
dropimages[0]="Vehicles/V1.jpg"
dropimages[1]="Vehicles/V2.jpg"
dropimages[2]="Vehicles/V3.jpg"
dropimages[3]="Vehicles/V4.jpg"
dropimages[4]="Vehicles/V5.jpg"
dropimages[5]="Vehicles/V6.jpg"
dropimages[6]="Vehicles/V7.jpg"
dropimages[7]="Vehicles/V8.jpg"
dropimages[8]="Vehicles/V9.jpg"

var droplinks=new Array()
//SET IMAGE URLs. Use "" if you wish particular image to NOT be linked:
droplinks[0]=""
droplinks[1]=""
droplinks[2]=""
droplinks[3]=""
droplinks[4]=""
droplinks[5]=""
droplinks[6]=""
droplinks[7]=""
droplinks[8]=""


////NO need to edit beyond here/////////////

var preloadedimages=new Array()
for (p=0;p<dropimages.length;p++){
preloadedimages[p]=new Image()
preloadedimages[p].src=dropimages[p]
}

var ie4=document.all
var dom=document.getElementById

if (ie4||dom)
document.write('<div onmouseover="rotateimage.pause = true;" onmouseout="rotateimage.pause = false;" style="position:relative;width:'+slideshow_width+';height:'+slideshow_height+';overflow:hidden"><div id="canvas0" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';background-color:'+slidebgcolor+';left:-'+slideshow_width+'"></div><div id="canvas1" style="position:absolute;width:'+slideshow_width+';height:'+slideshow_height+';background-color:'+slidebgcolor+';left:-'+slideshow_width+'"></div></div>')
else
document.write('<a href="javascript:rotatelink()"><img name="defaultslide" src="'+dropimages[0]+'" border=0></a>')

var curpos=parseInt(slideshow_width)*(-1)
var degree=10
var curcanvas="canvas0"
var curimageindex=linkindex=0
var nextimageindex=1

function movepic(){
if (curpos<0){
curpos=Math.min(curpos+degree,0)
tempobj.style.left=curpos+"px"
}
else{

clearInterval(dropslide)
nextcanvas=(curcanvas=="canvas0")? "canvas0" : "canvas1"
tempobj=ie4? eval("document.all."+nextcanvas) : document.getElementById(nextcanvas)
var slideimage='<img src="'+dropimages[curimageindex]+'" border=0>'
tempobj.innerHTML=(droplinks[curimageindex]!="")? '<a href="'+droplinks[curimageindex]+'" target="_blank">'+slideimage+'</a>' : slideimage
nextimageindex=(nextimageindex<dropimages.length-1)? nextimageindex+1 : 0
setTimeout("rotateimage()",pause)
}
}

function rotateimage(){
if(rotateimage.pause){
setTimeout(rotateimage, pause);
return;
}
if (ie4||dom){
resetit(curcanvas)
var crossobj=tempobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.style.zIndex++
var temp='setInterval("movepic()",50)'

dropslide=eval(temp)
curcanvas=(curcanvas=="canvas0")? "canvas1" : "canvas0"
}
else
document.images.defaultslide.src=dropimages[curimageindex]
linkindex=curimageindex
curimageindex=(curimageindex<dropimages.length-1)? curimageindex+1 : 0
}

function rotatelink(){
if (droplinks[linkindex]!="")
window.open(droplinks[linkindex])
}

function resetit(what){
curpos=parseInt(slideshow_width)*(-1)
var crossobj=ie4? eval("document.all."+what) : document.getElementById(what)
crossobj.style.left=curpos+"px"
}

function startit(){
var crossobj=ie4? eval("document.all."+curcanvas) : document.getElementById(curcanvas)
crossobj.innerHTML='<img src="'+dropimages[curimageindex]+'" border=0>'
rotateimage()
}

if (ie4||dom)
window.onload=startit
else
setInterval("rotateimage()",pause)
</script>

The browser cache may need to be cleared and/or the page refreshed to see changes.

rmather
12-04-2013, 02:57 PM
Thanks so much! This works great!
Ruth