Skip to content

Instantly share code, notes, and snippets.

@jcf
Created December 1, 2009 17:06
Show Gist options
  • Save jcf/246442 to your computer and use it in GitHub Desktop.
Save jcf/246442 to your computer and use it in GitHub Desktop.
(function($) {
$.localStorage = function(key, value) {
if (localStorage == null) {
return console.log('Local storage not supported!');
} else {
try {
if (typeof value != 'undefined') {
localStorage.setItem(key, value);
result = value;
} else {
result = (value === null) ? localStorage.removeItem(key) :
localStorage.getItem(key);
};
return result;
} catch(err) {
private_browsing_error = 'Unable to store local data. Are you using Private Browsing?';
/QUOTA_EXCEEDED_ERR/.test(err) ? alert(private_browsing_error) : throw(err);
};
};
};
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment