Last active
August 29, 2015 14:03
-
-
Save ShivrajRath/9944dce699bbae12f614 to your computer and use it in GitHub Desktop.
'Storage' Event on localstorage
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
| /** | |
| * This is called when setItem(), removeItem(), or clear() changes something on localstorage | |
| * This event not triggered for the tab/window where the event is initiated. It is triggered in other tabs | |
| */ | |
| localStorage.setItem('locKey', '1'); | |
| var fn = function (event) { | |
| if (event.key == 'locKey') { | |
| console.log("Old Value : " + event.oldValue); | |
| console.log("New Value : " + event.newValue); | |
| console.log("Url : " + event.url); | |
| } | |
| }; | |
| window.addEventListener('storage', fn, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment