-
-
Save JaosnHsieh/ca425d116964af5cb30a759a0004cf40 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