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