Home >Web Front-end >JS Tutorial >js leave or refresh page detection (and compatible with FF, IE, Chrome)_javascript skills

js leave or refresh page detection (and compatible with FF, IE, Chrome)_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:57:101348browse
Copy code The code is as follows:




<script><br> function closeIt()<br> {<br> return "Any string value here forces a dialog box to n" <br> "appear before closing the window." ;<br> }<br> window.onbeforeunload = closeIt;<br></script>


Click here to navigate to
      www.jb51.net




Compatible with FF, IE, and Chrome js detection for leaving or refreshing the page, the key part is to have return
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn