Gokhan Posted October 24, 2014 Share Posted October 24, 2014 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 More sharing options...
justsomeguy Posted October 24, 2014 Share Posted October 24, 2014 It's possible that local storage doesn't work unless you're on a web server as opposed to opening the file from your hard drive. Link to comment Share on other sites More sharing options...
Gokhan Posted October 24, 2014 Author Share Posted October 24, 2014 It's possible that local storage doesn't work unless you're on a web server as opposed to opening the file from your hard drive. You are right, it works on the local server. Thanks a lot. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now