Local Storage
HTML5 Storage provides a way for websites to store information on your computer and retrieve it later. The concept is similar to cookies, but itâs designed for larger quantities of information. Cookies are limited in size, and your browser sends them back to the web server every time it requests a new page (which takes extra time and precious bandwidth). HTML5 Storage stays on your computer, and websites can access it with JavaScript after the page is loaded.
Checking for HTML5 Storage support uses detection technique #1 (see
Detection Techniques). If your browser supports HTML5
Storage, there will be a localStorage
property on the global window
object.
If your browser doesnât support HTML5 Storage, the localStorage
property will be undefined. You can
check for local storage support using this function:
function supports_local_storage() { return ('localStorage' in window) && window['localStorage'] !== null; }
Instead of writing this function yourself, ...
Get HTML5: Up and Running now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.