IE中的onbeforeunload事件消息错误?

时间:2012-06-22 05:09:09

标签: jquery internet-explorer onbeforeunload

当应用程序在Internet Explorer中关闭时,我使用以下事件进行调用。工作​​正常,这意味着当我关闭IE浏览器Tab.And时会调用     我的问题是如果我关闭窗口我收到来自网页的消息,我收到带有该消息的'False'语句。如果我在此函数中删除了返回false语句,我没有     访问该函数。如何从消息框中隐藏False语句?     enter image description here

window.onbeforeunload = function(event) 
{

           if($.browser.msie)
           {
               alert('Test');
               return false;
            }

 }    

3 个答案:

答案 0 :(得分:0)

试试这个:

返回Cusom消息而不是False

window.onbeforeunload = function(event) 
{   
return "Are you sure ";       
}    

答案 1 :(得分:0)

在所有主要网络浏览器的更高版本中,您无法取消“导航”。您唯一能做的就是向用户显示一条消息。这是通过返回一个字符串来实现的:

window.onbeforeunload = function() {return "your message goes here";}

“Ok”和“Cancel”按钮以及周围的文本由浏览器控制,因为在互联网的早期阶段滥用了这一功能。甚至不依赖于显示的自定义消息。例如,Firefox只是说该页面试图阻止您导航但不会显示您的自定义消息。

答案 2 :(得分:0)

试试这个:

window.onbeforeunload = function(event) 
{

           if($.browser.msie)
           {
               alert('Test');
               return "";
            }

 } 
相关问题