-
-
Save alextanhongpin/188efd9864d7d55358e4760766bb8d4a to your computer and use it in GitHub Desktop.
Local storage event listeners
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> | |
<title>localStorage Test</title> | |
<script type="text/javascript" > | |
var count = 0; | |
var storageHandler = function () { | |
alert('storage event 1'); | |
}; | |
window.addEventListener("storage", storageHandler, false); | |
</script> | |
</head> | |
<body> | |
In Page 1 | |
<button id="addBtn" | |
onclick="localStorage.setItem('key1',count++)"> | |
Add | |
</button> | |
<button id="clearBtn" | |
onclick="localStorage.clear()"> | |
Clear | |
</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment