I want to communicate between two different tabs in the same browser (on the same domain).
When a specific event fires in the second tab, I change a localstorage variable value (using Javascript). I want to detect this change on the first tab. The variable is named “status” and the value changes from 0 to 1
I was thinking for a possible solution and I think that using a timer on the first tab will work, but I think also that there must be a better way.
Do you know if there is any way to detect when the “status” variable value changes without using a timer?
Thanks a lot!
It seems that Storage events should provide what you need.
The HTML spec on storage events ( http://dev.w3.org/html5/webstorage/#the-storage-event )
says :
Note the final clause, all windows which have access to the storage should be notified of any change.
However note the following clause in previous section of the spec :
So the document which provoked the change is not alerted.