English 中文(简体)
我怎么能够区分所有的定时活动?
原标题:How can I disable all setTimeout events?

我使用的是Ajax和Asp.net。 iI拥有一个“javascript”功能,它产生许多其他带有固定时间的javascript功能。 在出现同步的退步之后,我要对所有这些既定事件表示不满。 我如何能够这样做?

最佳回答

当你打电话settimeout()时,储存时间识别器,以便你能够加以澄清。 如果你重新创造许多时间,那么一个阵列是存放这些身份证的良好选择。 例如:

var timeouts = [];
//then, store when you create them
timeouts.push( setTimeout( { ... }, 1000) );

那么,当你们想要清除这些地雷时:

for (var i = 0; i < timeouts.length; i++) {
    clearTimeout(timeouts[i]);
}
//quick reset of the timer array you just cleared
timeouts = [];

http://developer.mozilla.org/en/DOM/window.cleartimeout” rel=“noreferer”cleartimeout(。 如果已经发生停职,就没有出现种族/激化问题。

问题回答

如果你不能进入规定时间的人为尼克岛的答案可能不会奏效的法典,那么我可以认为的就是这个黑板。

www.un.org/Depts/DGACM/index_spanish.htm 这是一种 ha,谨慎使用!

// Set a fake timeout to get the highest timeout id
var highestTimeoutId = setTimeout(";");
for (var i = 0 ; i < highestTimeoutId ; i++) {
    clearTimeout(i); 
}

基本上,它贪.得最久,而且比这更清楚。 But 还可以向其他时间人表明,你不想清除!

不清楚你是否能够在全球做到这一点,但最常见的方法是使用cleartimeout 。 你们把定时的回报值转嫁给明时日,你可以使用全球var来储存所有排时段。

首先,我使用这一法典:

var x = setTimeout(  );
for (var i = 0; i < x; i++)
    clearTimeout(x);

然而,这一代号和平并没有在谷歌 Chrome上发挥作用。 因此,我对此作了改进:

var x = setTimeout( alert("x"); ,100000); //It is very low probability that after 100 seconds x timeout will not be cleared
for (var i = 0; i <= x; i++)
    clearTimeout(i);

www.un.org/Depts/DGACM/index_spanish.htm 最后,正如上述评论中所提到的那样,它是一种黑板,因此加以认真使用。

Edit:固定错误变量在循环中使用(使用i而不是x)

您可使用<条码>或其他功能的<条码>

var myVar;

function myFunction() {
  myVar = setTimeout(function(){ alert("Hello"); }, 3000);
}

function myStopFunction() {
  clearTimeout(myVar);
}




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签