上的Internet Explorer的window.open和AJAX调用调用window.onbeforeunload [英] Internet Explorer calling window.onbeforeunload on window.open and AJAX calls

查看:148
本文介绍了上的Internet Explorer的window.open和AJAX调用调用window.onbeforeunload的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我花了一段时间这个问题,这是我收集了:

Ok, I have spent a while on this problem and this is what I have gathered:

  1. 如果你做在IE7中的AJAX调用,你必须指定一个window.onbeforeunload功能,它调用onbeforeunload的功能。

  1. If you make an AJAX call in IE7 and you have a window.onbeforeunload function specified, it calls the onbeforeunload function.

如果您尝试打开使用的window.open一个新的窗口,而不会干扰当前窗口的onbeforeunload的被调用。

If you try to open a new window with window.open WITHOUT disturbing the current window, the onbeforeunload gets called.

有谁知道如何停止?我甚至尝试了变量设置为TRUE,并检查该变量在我onbeforeunload的功能,它仍然dosent工作!我只需要能够阻止这种方法AJAX调用和新窗口调用执行。

Does anyone know how to stop this? I even tried setting a variable to TRUE and check that variable in my onbeforeunload function and it still dosent work! I just need to be able to stop the execution of that method for AJAX calls and new window calls.

推荐答案

另外,可能更简单的方法是,当你打开弹出返回false:

Another and probably simpler option is to return false when you open the popup:

<a onclick="window.open(...); return false;" href="javascript:;" >my link</a>

这似乎停止从IE以为你离开页面,并触发该事件。所有其他选项不是特别可行的我。

This seems to stop IE from thinking you're leaving the page and triggering the event. All the other options weren't particularly viable for me.

这篇关于上的Internet Explorer的window.open和AJAX调用调用window.onbeforeunload的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆