admin管理员组文章数量:1318034
I have an issue that is only a problem in IE8, go figure.
I have a anchor tag with an onclick attribute
<a href="javascript:void(0);" onclick="foo();">Click Me</a>
and then foo is declared elsewhere:
<script type="javascript/text">
function foo(){
//do some work
return false;
}
</script>
After foo is called, my onbeforeunload handler is being executed, and I have no idea why.
I have had other instances, if the foo function does not return false, it triggers the beforeunload event in IE, but even with this function returning false, it still hits my onbeforeunload handler and I can't figure out why.
Is there any way to find out what is triggering it. I have viewed the event object inside my onbeforeunload handler, but it doesn't not seem to give me and relevant info.
Any Ideas?
I have an issue that is only a problem in IE8, go figure.
I have a anchor tag with an onclick attribute
<a href="javascript:void(0);" onclick="foo();">Click Me</a>
and then foo is declared elsewhere:
<script type="javascript/text">
function foo(){
//do some work
return false;
}
</script>
After foo is called, my onbeforeunload handler is being executed, and I have no idea why.
I have had other instances, if the foo function does not return false, it triggers the beforeunload event in IE, but even with this function returning false, it still hits my onbeforeunload handler and I can't figure out why.
Is there any way to find out what is triggering it. I have viewed the event object inside my onbeforeunload handler, but it doesn't not seem to give me and relevant info.
Any Ideas?
Share Improve this question asked Feb 18, 2011 at 22:06 MattoToddMattoTodd 15.2k16 gold badges63 silver badges77 bronze badges3 Answers
Reset to default 7Change it to
<a href="#" onclick="return foo();">Click Me</a>
or
<a href="#" onclick="foo();return false;">Click Me</a>
There's also this thread over at microsoft "answers": http://answers.microsoft./en-us/ie/forum/ie8-windows_other/ie8-fires-onbeforeunload-when-clicking-a/0ac8cd9b-7483-4e16-b7c4-346df1f1499a :)
I had this issue as well on some anchor tags that were being rendered by CK Editor. Fixed by attaching a click event to a DIV that surrounded the anchor tags in question and stopped events from propagating to the window:
$('div.cke_form_fix').on('click', function(e){
e.stopPropagation();
});
本文标签: javascriptIE8 What is tiggering beforeunload eventStack Overflow
版权声明:本文标题:javascript - IE8 What is tiggering beforeunload event - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741992257a2409341.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论