HTML5 the localstorage of offline storage in 5 of web

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.