js捕捉瀏覽器關閉事件-兼容幾乎所有瀏覽器


很多時候我們都在困擾,如何捕獲瀏覽器關閉事件,網上雖然有很多方法,但都不理想,后來終於找到了一個很好地實現方法,大家可以試試哦,支持幾乎所有的瀏覽器

<script type="text/javascript">
var READYTOPROCESS = false; window.onbeforeunload = function closeWindow(e) { if (!READYTOPROCESS) { //message to be returned to the popup box. var message = '你確定要關閉嗎?', e = e || window.event; if (e) e.returnValue = message; // IE return message; // Safari } }; </script>


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM