0
之前控制页面我使用的功能如何关闭窗口
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
或'留在本页面上'执行功能?
我们怎样才能找到按钮“leavethispage”和“stayonthispage”,我们如何分配点击事件 – Jonathan
@ DoorknobofSnow好,编辑。 – Cilan