2013-02-01 27 views
2

當用戶離開頁面時,我正在使用window.onbeforeunload進行用戶確認。 但是確認警報只在IE中發生兩次。刷新URL時,兩次獲取onbeforeunload確認警報?

我的代碼,

<%@ page language="java" contentType="text/html; charset=UTF-8" 
    pageEncoding="UTF-8"%> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<title>User confirmation</title> 

<script type="text/javascript"> 
    /* Used for confirmation , to closing the window */ 
    window.onbeforeunload = function() { 

     return "Are you sure want to LOGOUT the session ?"; 
    }; 
</script> 
</head> 
<body> 
<p>Folow the steps which I said in Stack overflow</p> 
</body> 
</html> 

的情況是,

第1步:運行我的代碼,並在IE中打開它。

第2步:加載應用程序後,關閉瀏覽器窗口。您將收到確認提醒。

第3步:在確認提醒中給取消

第4步:然後通過在地址欄中按ENTER按鈕刷新URL。

第5步:給確定在提醒中。

第6步:現在您將再次收到確認提醒。

任何人都可以告訴我如何解決這個問題。

+0

你嘗試計時器的解決方法? – giammin

+0

它沒有工作... –

回答