-
转载:解决IE下a标签会触发window.onbeforeunload的问题
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
- <html>
-
- <head>
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
-
- <script type="text/javascript">
- window.onbeforeunload=function(){
- return "56456456";
- }
- function testMothed(){
- alert("555");
-
- }
- </script>
- </head>
-
- <body>
- 点a标签时事件调用顺序:onclick->window.onbeforeunload->href
-
- 在IE中点击A标签会触发window.onbeforeunload事件,这有时会给我们带来麻烦。
-
- 我知道的有两种解决方法:1、<a href=”###”/>3个#号可以防止锚点,2、根据事件顺序onclick="return false;"不执行window.onbeforeunload->href两个事件。
-
- 测试1、测试2、测试3 都不会触发window.onbeforeunload事件。
-
- <a href="javascript:void(0);">测试0</a>
- <a onclick="return true;" href="#">测试1</a>
- <a onclick="return true;" href="###">测试2</a>
- <a onclick="testMothed();return false;" href="javascript:alert(22)">测试3</a>
- <a onclick="testMothed();" href="javascript:alert(22)">测试4</a>
-
- </body>
- </html>
- 原文:http://nikoo.blog.51cto.com/211591/1026668
-
相关阅读:
奶牛碑文
快速幂算法——人见人爱A^B
杨辉三角
iis404 没有设置mime的后缀
jquery的click和js的funcition中的参数不一样
asp:timer的权限与操作注意
.net 文件上传,只上传修改的东西
vscode的配置 和xdebug配制
emoji编码后存储
php 服务器请求其它网页的方法
-
原文地址:https://www.cnblogs.com/IcefishBingqing/p/6432534.html
Copyright © 2020-2023
润新知