Skip to content

Instantly share code, notes, and snippets.

@hilotech
Created April 10, 2015 01:08
Show Gist options
  • Save hilotech/3fe3c41c74600dafc435 to your computer and use it in GitHub Desktop.
Save hilotech/3fe3c41c74600dafc435 to your computer and use it in GitHub Desktop.
localStorage test
<!DOCTYPE html>
<title>localStorage test</title>
<body>
<h1>localStorage test</h1>
<script>
if ( ! window.console ) {
console = {
log : function( s ) {
alert( s );
}
}
}
var isEnabledLocalStorage = false;
try {
if ( !window.localStorage ) {
console.log( 'window.localStorage property does not exist.' );
} else {
console.log( 'window.localStorage propety exists.' );
isEnabledLocalStorage = true;
if ( window.localStorage === null ) {
console.log( 'window.localStorage is null.' );
isEnabledLocalStorage = false;
}
}
} catch (e) {
console.log( 'window.localStorage propety causes exception.' );
}
console.log( isEnabledLocalStorage );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment