Forum Moderators: open
var delayb4scroll=0 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=2 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?
copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
function scrollmarquee(){
if (parseInt(cross_marquee.style.left)>(actualwidth*(-1)+8))
cross_marquee.style.left=parseInt(cross_marquee.style.left)-copyspeed+"px"
else
cross_marquee.style.left=parseInt(marqueewidth)+8+"px"
}
function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.left=0
marqueewidth=document.getElementById("marqueecontainer").offsetWidth
actualwidth=cross_marquee.offsetWidth
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}
Every time the user clicks the button, another setInterval is triggered, the first one isn't cancelled. So if the user clicks 3 times, the scrollmarquee function is called 3 times per cycle.
The solution, you are capturing the interval id into lefttime with this command in the setTimeout function:
lefttime=setInterval("scrollmarquee()",30) Now, add the line:
clearInterval( lefttime);
You may have to add a global var lefttime at the top where you have pauseit and the others.