if(window.opera){
window.onunload = confirmUnload;
}else{
window.onbeforeunload = confirmExit;
}
function confirmUnload(){
if(confirm('blah')){
return true;
}else{
location = self.location;
}
};
function confirmExit(){
return 'blah';
};
window.onunload = confirmUnload;
}else{
window.onbeforeunload = confirmExit;
}
function confirmUnload(){
if(confirm('blah')){
return true;
}else{
location = self.location;
}
};
function confirmExit(){
return 'blah';
};
本文介绍了一种使用JavaScript实现的页面卸载前确认对话框的方法。通过检测浏览器类型,分别利用onunload或onbeforeunload事件触发确认消息。如果用户选择离开,则页面正常跳转;若取消,则留在当前页面。
2077

被折叠的 条评论
为什么被折叠?



