Skip to content

Instantly share code, notes, and snippets.

@treasonx
Created April 17, 2012 19:06
Show Gist options
  • Save treasonx/2408334 to your computer and use it in GitHub Desktop.
Save treasonx/2408334 to your computer and use it in GitHub Desktop.
Firefox localStorage Issues
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>LocalStoreBug</title>
</head>
<body>
<script type="text/javascript" charset="utf-8">
var v = localStorage.getItem('baz');
if(v) {
console.log(v);
//Uncomment the following reading of localStorage and everything will work as expected!
//console.log(localStorage);
localStorage.removeItem('baz');
console.log(localStorage);
} else {
localStorage.setItem('foo', 'thing');
localStorage.setItem('bar', JSON.stringify({obj:'thing'}));
localStorage.setItem('baz', '1');
console.log('Baz Not Found Refresh');
console.log(localStorage);
}
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment