Skip to content Skip to sidebar Skip to footer

Html5 Code Not Working In Ie9

The following simple code works in Firefox (12.0) but does not seem to work in IE 9 even though local storage is supported in IE9. Notice how alert(localStorage.lastname); does

Solution 1:

Never set/get the items in localstorage directly! Use the appropriate methods for that:

localStorage.setItem(key,value)
localStorage.getItem(key)
localStorage.removeItem(key)

This fixes your IE problem and you will live happily :-D

(Note, that the values are stores as strings!)

Solution 2:

Your code will work fine on IE if you host your HTML file on web server.

If you are opening file:// url in IE, then localStorage will be undefined. Try confirming that with if(typeof(localStorage)!=="undefined") and you will get "Sorry, your browser does not support web storage..."

Solution 3:

actually it doesnt even work from a webserver. i am running a web app on websphere application server and i get the same issue on ie9. it works fine on chrome.

you can try the stuff on this page: http://html5doctor.com/storing-data-the-simple-html5-way-and-a-few-tricks-you-might-not-have-known/

Post a Comment for "Html5 Code Not Working In Ie9"