我想在窗口卸载之前更改浏览器消息,以下是正在尝试处理的代码
var displayMessage = true;
$(window).bind('beforeunload', function(){
if(displayMessage){
var message = '-- You specify a custom message here ---'+'\n Thanks for visiting my site!';
return message;
}
});
使用上面的代码,我在 Firefox 上收到的消息是
This page is asking you to confirm that you want to leave - data you have entered may not be saved.
如何将其更改为自定义消息
最佳答案
你将无法这样做
来自 Mozilla.org “请注意,在 Firefox 4 及更高版本中,返回的字符串不会向用户显示。相反,Firefox 会显示字符串“此页面要求您确认是否要离开 - 您输入的数据可能会无法得救。”
更多信息:https://developer.mozilla.org/en-US/docs/WindowEventHandlers.onbeforeunload
关于javascript - 如何更改卸载前浏览器的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25806275/