JavaScript localStorage object broken in IE11 on Windows 7
Turns out this is a problem in the base version of IE11 (11.0.9600.16428) for Windows 7 SP1.
After installing a patch to update to 11.0.9600.16476 (update version 11.0.2 - KB2898785) the issue gets resolved. Links to other versions of Windows (32-bit etc.) can be found at the bottom of the patch download page.
localstorage on Internet Explorer not working
Adding the doctype declaration means your mark-up is resolved by the browser the way it should (i.e. as HTML5).
Internet Explorer has a couple of issues with local storage. First of all, it doesn't work at all in versions prior to 8 -- you don't specify the version you're running in your post.
Important: you mention you are running on your C: drive: does this mean you are using the file://
protocol rather than http? if so, problem solved. Using the file protocol will cause various issues, not least that localStorage
simply won't work in IE.
If you're still having issues, you may find you need to tinker with the browser's security settings to allow local storage.
This page includes a matrix detailing localStorage support in the various browsers:
http://www.html5rocks.com/en/features/storage
Be sure to check out Mark Pilgrim's excellent HTML5 resource, which includes some IE-specific code for detecting the storage
event:
http://diveintohtml5.info/storage.html
using localStorage.setItem Internet explorer
- Please check this option in IE 11, if this option is disabled, storage object will be undefined in IE:
- Click the "Tools" menu and choose "Internet Options".
- Click on the tab labeled "Advanced".
- Check the box for "Enable DOM Storage".
- Click "Apply", click "OK".
localstorage
can't work withfile://
protocal, you need to run the page through http protocal.- There might be issues with
localstorage
in old version of IE 11 in win7/win8, please make sure you have installed the latest update.
localStorage in win8.1 IE11 does not synchronize
I've found a workaround for this issue on Win 10. If you handle the window.onstorage event in your code then localStorage will refresh for all open tabs.
Something as simple as this worked for me:
window.onstorage = function(e){
//Leave this empty
//or add code to handle
//the event
};
I haven't tested this code thoroughly, so please do so before using this method in any production apps.
Hope this helps!
window.sessionStorage issue in IE, when webpage is not run on localhost
I found my answer on: Local website renders differently using (IP address or machine name) vs localhost?
Turns out, that the issue was with my html, not my javascript. I added this line in my head tag:
<meta http-equiv="X-UA-Compatible" content="IE=11">
and that fixed it.
Related Topics
HTML Input Type=File, Get the Image Before Submitting the Form
Check a Radio Button with JavaScript
How to Remove Tinymce and Then Re-Add It
How to Do a Horizontal Scroll on Mouse Wheel Scroll
How to Access Shadow Dom Elements Through the Parent Document
Getting Bootstrap's Modal Content from Another Page
Want HTML Form Submit to Do Nothing
How to Use Greasemonkey to Selectively Remove Content from a Website
Setting CSS Value Limits of the Window Scrolling Animation
Make Function Wait Until Element Exists
Integrating Dropzone.Js into Existing HTML Form with Other Fields
Get the Text Content from a Contenteditable Div Through JavaScript
How Does Basic Object/Function Chaining Work in JavaScript
Building a Promise Chain Recursively in JavaScript - Memory Considerations
How to Check If the User Can Go Back in Browser History or Not
How to Fix Navigator/Window/Document Is Undefined in Nuxt
Difference Between HTMLcollection, Nodelists, and Arrays of Objects