localStorage object is undefined in IE
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.
localstorage on Internet Explorer not working
Adding the doctype declaration means your mark-up is resolved by the browser the way it should (i.e. as HTML5).
Internet Explorer has a couple of issues with local storage. First of all, it doesn't work at all in versions prior to 8 -- you don't specify the version you're running in your post.
Important: you mention you are running on your C: drive: does this mean you are using the file://
protocol rather than http? if so, problem solved. Using the file protocol will cause various issues, not least that localStorage
simply won't work in IE.
If you're still having issues, you may find you need to tinker with the browser's security settings to allow local storage.
This page includes a matrix detailing localStorage support in the various browsers:
http://www.html5rocks.com/en/features/storage
Be sure to check out Mark Pilgrim's excellent HTML5 resource, which includes some IE-specific code for detecting the storage
event:
http://diveintohtml5.info/storage.html
Undefined local storage item on Internet Explorer
Go to devtool (F12) --> go to "Console" tab and enter localStorage.
OR
Try to add it on the watchlist: "Script" tab -> observe -> enter localStorage & refresh for see the change.
Even i am using the same.Just refresh and check :
JavaScript localStorage object broken in IE11 on Windows 7
Turns out this is a problem in the base version of IE11 (11.0.9600.16428) for Windows 7 SP1.
After installing a patch to update to 11.0.9600.16476 (update version 11.0.2 - KB2898785) the issue gets resolved. Links to other versions of Windows (32-bit etc.) can be found at the bottom of the patch download page.
Object method is undefined after retrieved from local storage?
local storage can only handle json data
json doesnt have functions
var book = new Book("Book title", "Book author", "512", "In Progress");
localStorage.book = book;
function parseBook(book){
return new Book(book.title, book.author, book.numPages, book.readStatus)
}
parseBook(localStorage.book).changeStatus.. // this ll work
this is just raw code i havent tested but ll work for sure;) View localStorage in Internet Explorer - Cannot get name/value pairs
Using localStorage
to look at the data in the console in IE
does work.
What is happening in the example you posted is that the code is being ran on another domain.
LocalStorage
is sandboxed in a specific domain, including subdomains.
The demo code runs in run.plnkr.co
while the page you are viewing is plnkr.co
Therefore ngStorage-x
and ngStorage-y
is not in the dataset inside IE because you are viewing for plnkr.co
.
Chrome offers a resources
tab like what you are viewing to inspect other pages, but the chrome console itself would not have access to that pages LocalStorage
.
You can manually go to run.plnkr.co
in IE, and type localStorage
in the console, and you will see ngStorage-x
and ngStorage-y
values. (After you executed the code in the demo).
using localStorage.setItem Internet explorer
- Please check this option in IE 11, if this option is disabled, storage object will be undefined in IE:
- Click the "Tools" menu and choose "Internet Options".
- Click on the tab labeled "Advanced".
- Check the box for "Enable DOM Storage".
- Click "Apply", click "OK".
localstorage
can't work withfile://
protocal, you need to run the page through http protocal.- There might be issues with
localstorage
in old version of IE 11 in win7/win8, please make sure you have installed the latest update.
Related Topics
What Is the Most Efficient Way to Reverse an Array in JavaScript
How to Invoke "Click" Event Programmatically in D3
Updating Svg Element Z-Index with D3
React Doesn't Reload Component Data on Route Param Change or Query Change
Escaping Backslash in String - JavaScript
How to Check If an Array Is a Subset of Another Array in JavaScript
How to Use a Link to Call JavaScript
Jquery Convert Line Breaks to Br (Nl2Br Equivalent)
Focus Next Element in Tab Index
Node.Js Piping the Same Readable Stream into Multiple (Writable) Targets
Get the Current Year in JavaScript
How to Detect When a Tab Is Focused or Not in Chrome with JavaScript
Why Let and Var Bindings Behave Differently Using Settimeout Function
How to Test for Nan in JavaScript
How to Read JSON File with Fetch() in JavaScript