HTML5 the localstorage of offline storage in 5 of web
Today, HTML5 is becoming more and more popular, if you do not know the offline storage, it means that you lag a lot.
There are several ways to store HTML5 offline: Web SQL Database, localstorage, cookies, WebStorage, IndexedDB, FileSystem.
While Web SQL database currently has browser support, it is the only relational database structure that is stored, but the Internet and its maintenance and development are discontinued. I'm not going to say much.
Today we mainly look at Localstorage, the simplest local storage method.
Let's start with a small example.
<! DOCTYPE html><html><head> <meta charset="Utf-8"> <meta name="viewport" content="Width=device-width, initial-scale=1 "> <title>Use of localstorage in HTML5</title></head><body> <p>You browse the current page<span id="Count">N</span>Times.</P><script> if (!localstorage.pageloadcount) Localstorage.pageloadcount = 0; Localstorage.pageloadcount = parseint(localstorage.pageloadcount) + 1; document.getElementById (' count '). textcontent = Localstorage.pageloadcount; </script></body></html>
Look at the running effect
/** * Save/Update data */ function savedm(Datamodel){window.localstorage[' Datamodel '] = Datamodel;}/** * Obtaining data * / function getdm(){ varValue = window.localstorage[' Datamodel '];if(value) {returnValue }return "';}/** * Delete data * / function cleardm(){ if(window.localstorage[' Datamodel ']){Deletewindow.localstorage[' Datamodel ']; } }
Welcome everyone to follow my blog! If in doubt, please add QQ Group: 135430763 Study together!
HTML5 the localstorage of offline storage in 5 of web