internet-explorer-9local-storageisolatedstorage

local storage in IE9 fails when the website is accessed directly from the file system


Both statements window['localStorage'] and window.localStorage

are undefined when accessing the url "file:///C:/index.html"

Is localStorage off limits when running websites on the filesystem?

PS. I'm running the website on a Windows 7 phone hosting the website in isolatedStorage.


Solution

  • Yeah, IE9 doesn't support localStorage for local files. Not in any official documentation that I can find, but the same issue is described in this blog.

    You'll have to either host the website externally, or find some other method of persisting data. [Support for HTML5-style local storage is still in beta in many browsers, anyway. Especially for pages on the local filesystem.]

    You could try userdata behaviors, which is a pre-W3C solution developed by Microsoft for Internet Explorer. Not sure if it supports local filesystems, though. Links:

    1. http://www.javascriptkit.com/javatutors/domstorage2.shtml
    2. http://msdn.microsoft.com/en-us/library/ms531424(VS.85).aspx

    References:

    1. https://bugzilla.mozilla.org/show_bug.cgi?id=507361
    2. https://stackoverflow.com/a/7377302/1122351