I am not sure if IE8 fully supports localStorage. But I use the following method to detect
function supports_html5_storage()
{
try {
return 'localStorage' in window && window['localStorage'] !== null;
}
catch (e) {
return false;
}
}
Now IE returns true for 'localStorage' in window
But returns undefined for window['localStorage']
So should I update this method OR does IE8 indeed have local storage support ?
You can try to set and read localStorage.
Some browsers return a security error if cookies are disabled or you are working with file: protocol.
function hasStorage(){
try{
localStorage.setItem('test', '7');
if(localStorage.getItem('test')=== '7'){
localStorage.removeItem('test');
return true;
}
}
catch(er){}
return false;
}
alert(hasStorage())
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With