發送Ajax是點擊onbeforeunload的jQuery
window.onbeforeunload = function() {
return "You have made changes on this page that you have not yet confirmed. If you navigate away from this page you will lose your
unsaved changes"; }
在下面的代碼
離開按鈕時,當用戶試圖離開當前頁面我詢問用戶確認或者他/她想要是否離開頁面。有兩個按鈕'離開頁面'和'cancle'
如何知道用戶是否點擊離開按鈕,然後我必須發送ajax請求(即ajax請求在數據庫中執行一些操作)。
在此先感謝。
請顯示一些HTML嗎? – 2014-09-24 06:36:08
@AminJafari爲什麼你需要HTML? – Manwal 2014-09-24 06:42:26