开发者

In IE the onbeforeunload event is fired for links that don't unload the page

I am writing a plugin to a CMS (umbraco) and I wish to attach a warning dialog to various actions on the page, one such action is clicking a link (JavaScript links), in most browsers the following code works well:

$(".propertypane").delegate("a, a div", "click", function () { window.onbeforeunload = confirmNavigateAway; });

The following is an issue in IE because IE appears to trigger onbeforeunload 开发者_StackOverflow中文版event when any link is clicked, even though the link is not navigating away.

I've set up an example here: http://jsfiddle.net/DETTG/8/

Note: I do not have control over the ajax controls within the propertypane, they're written by third parties.


Maybe this page will help you?


If you remove "href" then it will work. But then you would need to style it as a link element and add the attribute onclick if you want to execute a function. Here is the updated version: http://jsfiddle.net/DETTG/34/

<a onclick="alert('do some ajax');" style="color:blue; text-decoration:underline; cursor:pointer">javascript</a>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜