Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
543 views
in Technique[技术] by (71.8m points)

internet explorer 9 - 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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...