- Home
- /
- Tutorials
- /
- JavaScript Tutorial
- /
- JavaScript Storage Events
JavaScript Storage & BOM
JavaScript Storage Events
The
storageevent fires in other tabs whenlocalStoragechanges.
This is how two open tabs on the same site can talk to each other.
It never fires in the tab that made the change.
Example
Example
javascript
window.addEventListener("storage", function (event) {
console.log(event.key + " changed to " + event.newValue);
});
console.log("listener attached");