Skip to content

Instantly share code, notes, and snippets.

@tomasperezv
Created March 16, 2013 10:14
Show Gist options
  • Save tomasperezv/5175807 to your computer and use it in GitHub Desktop.
Save tomasperezv/5175807 to your computer and use it in GitHub Desktop.
Example of listening to local storage changes
if (window.addEventListener) {
window.addEventListener("storage", onStorage, false);
} else {
window.attachEvent("onstorage", onStorage);
};
var onStorage = function(data) {
// Receive changes in the localStorage
}
@NeXTs
Copy link

NeXTs commented Nov 9, 2017

if (window.addEventListener) {
  window.addEventListener("storage", onStorage, false);
} else {
  window.attachEvent("onstorage", onStorage);
};

function onStorage(data) {
  // Receive changes in the localStorage
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment