IE8's default settings don't allow the use of cookies or local/session storage on pages served from the hard drive, even after you "Allow Blocked Content" to allow JavaScript execution. So when viewing C:\Documents and Settings\username\filename.html, Modernizr 1.6 will test true for localStorage or sessionStorage, but attempts to get or set storage items will result in "is null or not an object" errors because the window.localStorage/window.sessionStorage will return undefined in this case.
It's pretty easy to work around this:
tests['localstorage'] = function() {
try {
return ('localStorage' in window) && window['localStorage'] && window.localStorage !== null;
} catch(e) {
return false;
}
};
tests['sessionstorage'] = function() {
try {
return ('sessionStorage' in window) && window['sessionStorage'] && window.sessionStorage !== null;
} catch(e){
return false;
}
};