help me with this setTimeout() error

by 2 replies
3
Hi,

I worked to build a custom rotator banner, The rotator is working fine, but my client need to pause the rotation when the user mouseover the banner.

Here is the code i used,

var t;
function rotate_banner(){
var x = new Array("m_top","m_middle","m_middle","m_bottom");
for(i=1; i<=4;i++){
t = setTimeout("get_offer('"+ i +"','" + x[i-1] + "')",i*3000);
}
setTimeout("rotate_banner()",12000);
}

window.onload =rotate_banner();

By this function the rotator is working fine, but when i call another function when mouse over the banner pause_rotate().

function pause_rotate(){
clearTimeout(t);
t=0;
}

This function is not clearing the timeout, Please any one help me to stop the rotator when mouse over the banner.

Thanks.
#programming #error #javascript #settimeout
  • Looks like clearTimeout(t); stops one of "get_offer", not "rotate_banner()"?
    • [1] reply
    • Right, t is the ID for the timer for get_offer. You've not captured the timer ID for rotate_banner.

Next Topics on Trending Feed