I'm using localStorage in my JS application and I was wondering why IE9 claims localStorage == undefined
. As far as I know, IE8 supports it, is here any way to get it working in the new version?
The localStorage object stores the data like a persistent cookie, with no expiration date. The data will not be deleted when the browser is closed, and will be available when a user returns to the browser. IE also supports localStorage from IE8 but it does not support localStorage in IE7 and previous versions.
The localStorage property is a property on the window object, therefore it's not available on the server. Copied! If you got the error in the browser, make sure that you have not misspelled the localStorage keyword (should be camelCase).
Are you testing this on a local HTML file? i.e. a file:///
URL?
localStorage is only available on HTTP websites. That hasn't changed in IE9 Dev Preview.
IE 11 WORKS
All you need two do add file://127.0.0.1 to the trusted zones under the security tab (NOTE: make sure https check box IS not checked) add this line to the top or your script, depending on your code you may not need to unless you get could not connect to the internet.
!localStorage && (l = location, p = l.pathname.replace(/(^..)(:)/, "$1$$"), (l.href = l.protocol + "//127.0.0.1" + p)); if (typeof(Storage) != "undefined") { // Store localStorage.setItem("lastname", "Smith"); // Retrieve alert(localStorage.getItem("lastname")); } else { alert("Sorry, your browser does not support Web Storage..."); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With