js離開或刷新頁面檢測(且兼容FF,IE,Chrome)
更新時間:2014年03月05日 09:37:51 作者:
這篇文章主要介紹了js離開或刷新頁面檢測(且兼容FF,IE,Chrome)。需要的朋友可以過來參考下,希望對大家有所幫助
復(fù)制代碼 代碼如下:
<!DOCTYPE html>
<html>
<head>
<script>
function closeIt()
{
return "Any string value here forces a dialog box to \n" +
"appear before closing the window.";
}
window.onbeforeunload = closeIt;
</script>
</head>
<body>
<a href="http://www.dbjr.com.cn">Click here to navigate to
www.dbjr.com.cn</a>
</body>
</html>
兼容FF,IE,Chrome的js離開或刷新頁面檢測,關(guān)鍵的部分是要有return
相關(guān)文章
CheckBox多選取值及判斷CheckBox選中是否為空的實例
下面小編就為大家?guī)硪黄狢heckBox多選取值及判斷CheckBox選中是否為空的實例。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-10-10淺談addEventListener和attachEvent的區(qū)別
下面小編就為大家?guī)硪黄獪\談addEventListener和attachEvent的區(qū)別。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-07-07