Localstorage Object Is Undefined in Ie

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 :

Sample Image

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?

  1. local storage can only handle json data

  2. json doesnt have functions

so for acheive what you want to achieve just parse the json to object before calling that function. here is the pseudo code

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:

    1. Click the "Tools" menu and choose "Internet Options".
    2. Click on the tab labeled "Advanced".
    3. Check the box for "Enable DOM Storage".
    4. Click "Apply", click "OK".

Sample Image

  • localstorage can't work with file:// 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



Leave a reply



Submit