Alex Rivera | Logout

Does IE8 out-of-the-box have support for 'localStorage'

Asked 2010-08-10T19:48:25.967
50

I am trying to use the HTML5 feature localStorage. According to this blog it can be done using IE8, however when I try to use it I get a javascript error 'localStorage is null or not an object'

So my question: can localStorage be used by IE8 out-of-the-box? Here is my code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=8" />
    <title>IE8 - DOM Storage</title>
    <script type="text/javascript"> 
        function Save() {
            localStorage.setItem('key','value');            
        }        
    </script>
</head>
<body>        
    <button onclick="Save();">
        Save
    </button>  
</body>
</html>
Edit
Report

1 Answer

7

the comment of musicfreak was correct. Because this feature requires domain, I had to use it only through a live url (at least localhost) and not by opening it as a file from a disk.

There is no need to add window.localStorage as IE8 recognizes just localStorage as well.

answered 2010-08-11T13:10:46.773

Your Answer