Jump to content

Storage event


Gokhan

Recommended Posts

Hello All,

 

I have found an example on stackoverflow and tried it however it doesn't work for me.

<!DOCTYPE html><html><head><title>Chrome localStorage Test</title><script type="text/javascript" >var handle_storage = function () {alert('storage event');};window.addEventListener("storage", handle_storage, false);</script></head><body><button id="add" onclick="localStorage.setItem('a','test')">Add</button><button id="clear" onclick="localStorage.clear()">Clear</button></body></html>

If the HTML document is opened in two separate tabs and "Add" button is clicked on one of the tabs it is expected that the other tab shows an alert. However I couldn't make it work. I tried it on IE, Chrome and Opera. What can be the reason it doesn't work for me? Is it possible that my browsers don't allow to use the local storage?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...