📌  相关文章
📜  javascript 离开页面警告 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:01:29.185000             🧑  作者: Mango

代码示例1
window.addEventListener("beforeunload", function (e) {
    var confirmationMessage = 'It looks like you have been editing something. '
                            + 'If you leave before saving, your changes will be lost.';

    (e || window.event).returnValue = confirmationMessage; //Gecko + IE
    return confirmationMessage; //Gecko + Webkit, Safari, Chrome etc.
});