当鼠标移动时,计时器功能被取消==" 但实际上我希望它从头开始计算。
function w()
{
if (parent.C.location == "http://119.247.250.128/wasyoku/home/prime.html")
{ parent.C.location = "weather.html";
wTout = setTimeout(function(){ parent.C.location = "prime.html"; }, wT);
}
else { parent.C.location = "prime.html"; clearTimeout(wTout); }
}
document.onmousemove.clearTimeout(wTout);
我真的需要再次setTimeout(··?
wTout = setTimeout(function(){ parent.C.location = "prime.html"; }, wT);
答案 0 :(得分:0)
是的,如果您清除超时,则必须再次设置 您可以做的另一件事是在上次移动鼠标时设置变量,在ontimeout上设置另一个设置超时,如果您在XX秒内移动鼠标
答案 1 :(得分:0)
var sto = null;
function myTimeout() {
window.clearTimeout(sto);
sto = setTimeout(function() {
console.log("setTimeout's working");
}, 2000);
}
someElement.addEventListener('mousemove', function() {
myTimeout();
});