我正在做這樣一個彈出警報:JavaScript中,如何找到已按下哪個按鈕使用onbeforeunload
window.onbeforeunload = confirmExit;
function confirmExit()
{
return "Wait! Save up to $20 Today! \n nClick OK to Save";
}
當我關閉窗口,我獸醫
Stay on the page
和
Close the browser
或類似的東西
什麼我想要做的是:如果Stay on the page
選項已被選中,那麼我想eighter重定向用戶到另一個頁面或顯示一個jQuery的彈出。
一些類似於:
if (window.onbeforeunload = null){
location.assign('http://example.com');
}
但這不起作用。
任何想法?
感謝
相似的問題:http://stackoverflow.com/questions/1335727/onbeforeunload-confirmation-screen-custumization – v42
這樣的消息真的很煩人。您可能需要考慮刪除它,因爲用戶不會被它感到好笑。 – pimvdb