刷新 URL 时,打开卸载确认警报两次
Getting onbeforeunload confirmation alert twice, when refreshing the URL?
当用户离开页面时,我正在使用window.onbeforeunload
进行用户确认,但确认警报仅在IE中发生两次。
我的代码是:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>User confirmation</title>
<script type="text/javascript">
/* Used for confirmation , to closing the window */
window.onbeforeunload = function() {
return "Are you sure want to LOGOUT the session ?";
};
</script>
</head>
<body>
<p>Folow the steps which I said in Stack overflow</p>
</body>
</html>
场景是 ,
步骤1:运行我的代码并在IE中打开它。
步骤2:应用程序加载后,关闭浏览器窗口。您将收到确认警报。
步骤3:在确认警报中取消。
步骤4:然后按 输入 地址栏中的按钮。
第 5 步:在警报中给出确定。
步骤6:现在您将再次发出确认警报。
谁能告诉我如何解决这个问题?
这是
IE中的设计使然。
阅读列出引发该事件的所有内容的备注。
http://msdn.microsoft.com/en-us/library/ie/ms536907%28v=vs.85%29.aspx
您可以使用计时器来避免这种情况:
window.onbeforeunload 可能会触发多次
相关文章:
- Meteor Router数据函数被调用两次
- 从MySQL数据库中获取输入数据需要两次页面刷新
- Module.start()已激发两次
- Jquery点击事件必须点击两次
- Append元素在运行两次函数后不显示
- 防止双击执行两次jQuery post请求
- 我必须点击两次才能激活任何按钮操作(离子/角度)
- 单击jQuery会激发两次
- 如何避免在树上走两次
- button.单击两次删除附加操作后不工作
- 由于$compile,Javascript(Angular)嵌套指令加载了两次
- 发送前jQuery!确认警报两次
- Bootstrap3确认模式回调触发两次
- javascript 警报以确认值是否输入了两次
- DNN:dnn确认需要两次点击才能显示
- JavaScript/jQuery 在点击时,确认触发两次
- yii在提交按钮中显示确认消息两次
- 使用Cordova会弹出两次确认对话框
- 刷新 URL 时,打开卸载确认警报两次
- Javascript确认对话框出现两次;单击Element后返回