سؤال

Does anyone know if current IE9 Beta fully supports HTML5 "localStorage" functionality? Normally the test for "localStorage" support can be done with js code just like:

try {
    return  ('localStorage' in window) && window['localStorage'] !== null;
} catch (e) {
    return false;
}

Well, it seems that this kind of test returns "true" but if you try something like:

localStorage.removeItem ('key')

you get an error on the Javascript Console (SCRIPT16389 error). Any more info?

هل كانت مفيدة؟

المحلول

Not entirely sure what the problem here is, because localstorage has been functional in IE since version 8. See:

http://msdn.microsoft.com/en-us/library/cc197062%28VS.85%29.aspx
http://www.quirksmode.org/dom/html5.html

And also, this working example I whipped up: http://jsbin.com/ijega3/edit

نصائح أخرى

The reason your test returns true is that the statement: window['localStorage'] returns "undefined". Change your test to: window['localStorage'] != null (or != undefined) and it will return false.

My version (9.0.8112.16421IC) of IE9 does not seem to support localStorage either.

There was a regression with removeItem in IE9 beta.

A bug was filed on the Connect bug reporting database. https://connect.microsoft.com/IE/feedback/details/613497/web-storage-remove-method-not-working-according-to-the-spec

As you can see on Comparison of layout engines (HTML5) on Wikipedia Web Storage should be supported.

PS: IE9 is Trident 5.0. (thanks EricLaw -MSFT- for the mistake).

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top