Why does accessing the localStorage object in Internet Explorer fail?

I am working on a client problem where Modernizr unexpectedly does not detect support for the localStorage object in Internet Explorer 9. My page correctly uses the HTML 5 HTML type ( <!DOCTYPE html> ), and the developer tools report the page has IE9 browser mode and standard document mode IE9, so I expect this to work.

I was debugging in the next try / catch in Modernizr and found that a JavaScript error was raised as soon as the localStorage object gets access.

 tests['localstorage'] = function() { try { localStorage.setItem(mod, mod); localStorage.removeItem(mod); return true; } catch(e) { return false; } }; 

On some machines, the JavaScript error message The system cannot find the file specified. . On others, this is just an Invalid argument. , and Internet Explorer blocks exactly 5 minutes before it throws an error.

What causes access to the localStorage object to cause an error here in Internet Explorer?

+4
source share
2 answers

I found that the lowest-level subdomain corresponds to one of the reserved device names, as described in Restrictions on the file mask and file name properties in Internet Explorer, accessing the localStorage object will cause an error.

This problem probably occurs because internally Internet Explorer tries to access the file system using the reserved device name when accessing the localStorage object to satisfy the Storage initialization steps of the object .

This is, of course, a very important question, but if your page comes from the server with the lowest subdomain level, this is exactly any of con , prn , aux , clock$ , nul , com1 , com2 , com3 , com4 , com5 , com6 , com7 , com8 , com9 , lpt1 , lpt2 , lpt3 , lpt4 , lpt5 , lpt6 , lpt7 , lpt8 or lpt9 (for example, http://prn.example.com ), this may well be the reason why you see this problem.

Choosing a lower subdomain that was not a reserved device name in this situation solved the problem.

+9
source

We are facing a similar problem because we started CCleaner on the machine.

To solve:

Internet Options → Browsing History → Delete:

Be sure to check all the parameters except the very first (save the data of your favorite website).

We were able to fix and then reproduce this problem again using CCleaner and then fix it again.

Go to this site for more information: http://grekai.wordpress.com/2013/02/24/localstorage-the-system-cannot-find-the-path-specified/

+4
source

Source: https://habr.com/ru/post/1446151/


All Articles