最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to prevent IE11 pop up (Are you sure you want to leave this page) - Stack Overflow

programmeradmin4浏览0评论

I am working on a page that I have nothing to type but a dropdown to select, but in IE11 when I try to move on to the next page, it will pop up the message. I would like to prevent this pop up from happening. So I just wonder what is the default behavior of that pop up in IE11(As it does not appear in either Chrome or Firefox) and how to prevent the pop up

I am working on a page that I have nothing to type but a dropdown to select, but in IE11 when I try to move on to the next page, it will pop up the message. I would like to prevent this pop up from happening. So I just wonder what is the default behavior of that pop up in IE11(As it does not appear in either Chrome or Firefox) and how to prevent the pop up

Share Improve this question asked Mar 20, 2014 at 14:24 Frank TianFrank Tian 8073 gold badges10 silver badges22 bronze badges 2
  • 1 that "popup" sounds very much like the onbeforeunload popup. Are you sure you aren't using the onbeforeunload callback somewhere within your code? – Kevin B Commented Mar 20, 2014 at 14:38
  • 1 ↑↑↑ Please check: alert(window.onbeforeunload); – A. Wolff Commented Mar 20, 2014 at 14:38
Add a ment  | 

2 Answers 2

Reset to default 5

A more important question to ask is: "Why IE11 is popping up that alert?".

Are you leaving a secure page for an insecure one? I.e. make sure to call the secure booking API, or let the browser choose, by not explicitly specifying the protocol:

var url = '//api.booking_site.url/api_endpoint';

This will call either the secure or insecure version of the url depending if you're currently browsing a secure or insecure site.

If you just want to get rid of the pop-up, assuming the pop-up you mention is an alert box, you can overwrite alert:

window.alert = function() { return true; }

This looks like it's a result of the return value from onbeforeunload. Apparently, instead of returning null you should return nothing.

See also onBeforeUnload handler says null in IE

发布评论

评论列表(0)

  1. 暂无评论