LocalStorage Change Event Example



localStorage change event can be used for some interesting scenarios.

Example 1: Open another tab and communicate back from that as well as close it

Open Follower Window / Tab

(Note: You can open multiple tabs)

Changes done in the other tabs will be shown below

   




Example 2: Keep track of how long the page was opened for


Enter a valid URL in the field below (e.g. https://www.bing.com)

Duration will be shown below

   

Note: A simpler example to undestand

Reference: MDN