Created
February 19, 2013 14:41
-
-
Save 0xPr0xy/4986485 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <script> | |
| function myLoadHandler(evt) | |
| { | |
| if (evt.persisted) { | |
| alert('user returns to page from another tab'); | |
| return; | |
| } | |
| alert('loading new page'); | |
| } | |
| function myUnloadHandler(evt) | |
| { | |
| if (evt.persisted) { | |
| alert('user goes to new tab'); | |
| return; | |
| } | |
| alert('user truly leaves the page'); | |
| } | |
| if ("onpagehide" in window) { | |
| window.addEventListener("pageshow", myLoadHandler, false); | |
| window.addEventListener("pagehide", myUnloadHandler, false); | |
| } else { | |
| window.addEventListener("load", myLoadHandler, false); | |
| window.addEventListener("unload", myUnloadHandler, false); | |
| } | |
| </script> | |
| </head> | |
| <body> | |
| <div id="log_id"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment