I'm trying to use sessionStorage
to display a modal alert only once per session - and I'm trying to do this in IE versions < 9.
The alert will tell users how terrible their IE version < 9 is, and to please upgrade.
Using sessionStorage
works fine in IE 11. But in older versions of IE, I can't get it to take effect (sessionStorage
comes back as 'undefined or null'). I've tested this locally and on a live site. Does sessionStorage
even work in IE < 9, and if not, what's a good alternative I can use in these older IE versions to only display this alert once per 'session'?
My code looks like:
if (sessionStorage.getItem('browserCheck') !== 'true') {
// define alert function
// call alert function
sessionStorage.setItem('browserCheck','true');
}
So apparently, sessionStorage
is valid in IE 7 and 8.
I was just deleting my cache wrong in the browser before switching the dev tools emulator from IE11 to IE 7 or 8. I was able to fix this by unchecking the top box inside of the 'delete history' prompt in IE:
Earlier, sessionStorage
was coming back as 'undefined or null' in IE 7 and 8 in my dev tools console - but I think this was a because of a separate issue. It isn't undefined - it works.
I believe localStorage
actually is invalid in IE < 8 though - so if localStorage
is your problem, this link is helpful: HTML5 Local Storage fallback solutions