Javascript 如何在用户按F5键或单击浏览器时显示自定义的fancybox';s后退/关闭按钮?
我需要使用onbeforeunload事件或任何其他可能性显示fancybox,而不是本机确认框,我需要显示自定义的fancybox 这是我当前的代码。Javascript 如何在用户按F5键或单击浏览器时显示自定义的fancybox';s后退/关闭按钮?,javascript,jquery,Javascript,Jquery,我需要使用onbeforeunload事件或任何其他可能性显示fancybox,而不是本机确认框,我需要显示自定义的fancybox 这是我当前的代码。 window.onbeforeunload = function(e) { $.fancybox({ content : 'test' }); return false; // if this line commented, browser won't wait for confirmation
window.onbeforeunload = function(e) {
$.fancybox({
content : 'test'
});
return false; // if this line commented, browser won't wait for confirmation
}
请提供工作答案。谢谢。你需要这样的东西吗
function unload(){
$.fancybox('<div>Your custom element<div>');
}
$(document).ready(function() {
window.onbeforeunload=function() {
unload();
};
});
函数卸载(){
$.fancybox(“您的自定义元素”);
}
$(文档).ready(函数(){
window.onbeforeunload=函数(){
卸载();
};
});
是,但在显示带有是或否选项的fancybox后,页面需要等待,直到用户选择是(重新加载或关闭)或否(留在页面中)。。