Last active
May 3, 2018 08:02
-
-
Save luobotang/bd7a2af00daff3c7e7b7618e5b4d30bd to your computer and use it in GitHub Desktop.
pageshow demo
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> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=1, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>BFCache & pageshow</title> | |
</head> | |
<body> | |
<a href="https://www.baidu.com/">leave to baidu.com</a> | |
<div id="log"></div> | |
<script> | |
var count = 0 | |
window.addEventListener('load', () => log('on load')) | |
window.addEventListener('pageshow', (e) => log((++count) + ' - on pageshow, persisted: ' + e.persisted)) | |
function log(msg) { | |
var el = document.getElementById('log') | |
var text = document.createTextNode(msg) | |
el.appendChild(text) | |
el.appendChild(document.createElement('br')) | |
} | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment