设置超时问题 [英] settimeout problem
问题描述
大家好,
我已经在onbeforeunload上编写了一个使用setTimeout(''myclose = false'',100)的函数; -将myclose变量设置为100ms间隔后为假.
但是,当我从该页面导航到其他页面时,有时不会将其设置为false并保持为真-这种行为是不确定的,但很常见.
奇怪的是,当我在visula studio中放置断点并仅调试linebyline时,总是将其设置为false.
所以我增加了2000ms的睡眠时间,之后又调用了settimeout,但是一切都是徒劳的...
那是什么原因呢?
-Ajay Kale
Hi guys,
I have written a function on onbeforeunload which uses setTimeout(''myclose=false'',100); - which should set the myclose variable as false afte 100ms interval.
But when I navigate to some other page from this page, it sometimes is not set as false and remains true - this behaviour is uncertain but usual one.
The strange thing is that when I put breakpoint in visula studio and just debug linebyline , it is set set to false always.
So i added sleep for 2000ms, afte settimeout call, but all in vain ...
So what can be the reason ?
- Ajay Kale
推荐答案
您是否应将代码设为;
setTimeout( function () { myClose=false } , 100);
Should you not have the code as;
setTimeout( function () { myClose=false } , 100);
这篇关于设置超时问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!