Created
April 29, 2021 08:09
-
-
Save wtnabe/b14e680c436ead5602b106966eefddd4 to your computer and use it in GitHub Desktop.
戻るとかでページを離脱する際の event を捕捉できるか、実験
This file contains 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
<html> | |
<head> | |
<meta name="viewport" content="width=device-width"> | |
</head> | |
<body> | |
<script type="text/javascript" src="https://unpkg.com/page-lifecycle@0.1.2/dist/lifecycle.es5.js"></script> | |
<script type="text/javascript"> | |
lifecycle.addEventListener('statechange', (event) => { | |
console.log('statchange') | |
console.log(event) | |
// cannot stop | |
event.originalEvent.returnValue = false | |
event.originalEvent.preventDefault() | |
return false | |
}) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
see
捕捉はできるけど
window.beforeunload
のように cancel することはできない。