我也明白,它不可能与一个自定义更换beforeunload
对话框,然后,如果我们需要设置一个自定义的信息给用户,我们将不得不在我们beforeunload处理程序返回的字符串:如何在beforeunload显示它自己之前显示模态对话框?
{Custom message here set by returning a string in our beforeunload handler}
Are you sure you want to leave this page?
[Leave this page] [Stay on this page]
那么,如何在浏览器显示实际的beforeunload对话框之前显示自定义模式对话框(可能是jQuery)?
我当前的代码使用的fancybox:
window.onbeforeunload = function() {
$.fancybox({ 'type':'iframe', 'href':'/PopupOnExit.php' });
return "Special offer! Stay on this page for more details.";
};
然而,这首先显示浏览器的对话框,只有点击或者“留”或“离开”按钮,并在浏览器中显示我的模态对话框后。
有没有什么办法让我的模态对话框显示在浏览器的对话框之前?
哪个浏览器对话框? – Blaster
我用我指的浏览器对话框来编辑问题 – Obay