我正在使用该功能
window.onbeforeunload = function(){
if(sessionStorage.hasOwnProperty("teststatred")){
validNavigation = true;
leave_message = "You are in the middle of the test, Are you sure do you want to close the window?"
}
if (validNavigation)
{
if (!e) e = window.event;
e.cancelBubble = true;
e.returnValue = leave_message;
if (e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
}
return leave_message;
}
}
此功能将显示两个按钮的窗口:Leave this page
和Stay on this page
。当用户单击或“留在此页面上”时,如何执行功能Leave this page
?