同域iFrame中访问主窗口setTimeoutID
我试图提醒用户大约 30 秒内不活动。因此,在我的应用程序中,我设置了警报超时。
主窗口代码:
<script>
var timeoutID = setTimeout('alert("You are logged out due to inactivity.")', 30000);
</script>
iFrame :
<script>
$(document).ajaxStop(function(){
clearTimeout(timeoutID);
var timeoutID = setTimeout('alert("You are logged out due to inactivity.")', 30000);
});
</script>
现在,当我在 iFrame 中并执行某些操作时,我的主窗口警报仍然出现。不知道如何重置相同的 timeoutID。
I am trying to alert user for inactivity about 30 secs. So in my application I am setting timeout for alert.
Main window code:
<script>
var timeoutID = setTimeout('alert("You are logged out due to inactivity.")', 30000);
</script>
iFrame :
<script>
$(document).ajaxStop(function(){
clearTimeout(timeoutID);
var timeoutID = setTimeout('alert("You are logged out due to inactivity.")', 30000);
});
</script>
Now, when I am in iFrame and doing something my main window alert still comes. Not sure how to reset the same timeoutID.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
use
top.timeoutID
在设置新超时时也使用它,否则当您离开 iframe 时将无法访问超时。
还有一个错字:
fucntion
use
top.timeoutID
Use it also when setting the new timeout, otherwise you will not be able to access to the timeout when navigating away from the iframe.
there is also a typo:
fucntion