Firefox关闭浏览器

时间:2018-05-23 11:33:02

标签: javascript

我使用下面的方法检查浏览器点击它应该显示警告信息的按钮但是这里没有显示关闭时的警告信息???

function closing() {
var answer = confirm("Do you wnat to close this window ?");
    if (answer){
        netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserWrite');
        window.close();
    }
    else{
        stop;
    }
}

1 个答案:

答案 0 :(得分:1)

试试这个:

 window.onbeforeunload = function()
 {
     return "Already leaving?";
 }

https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload