<Body> <canvas id = "myCanvas" width = "300px;" height = "200px" style = "border: 1px solid #00ff00; "> </canvas> <script type =" text/javascript "> var c = document. getElementById ("myCanvas"); var cxt = c. getContext ("2d"); cxt. moveTo (0, 0); cxt. lineTo (150,60); cxt. lineTo (10, 60); cxt. stroke (); </script>
The basic usage of localstorage is as follows: the default storage quantity is string type.
If (localStorage. pageCount) {localStorage. pageCount = Number (localStorage. pageCount) + 1; // pageCount custom} else {localStorage. pageCount = 1;} document. write ("visit" + localStorage. pageCount + "time (s)"); </script>
In this way, a database in your local disk stores the data. I could not accept the data written to my local disk and could not find its exact location. So I found that Chrome is stored in the form of sqlite database files. In C: \ Users \ Username \ AppData \ Local \ Google \ Chrome \ User Data \ Default \ Local Storage, although the suffix is. localstorege is actually a database file of sqlite. You can open it with sqlite and see the data in it.
HTML5 introduces application caching, which means that web applications can be cached and accessed when there is no Internet connection.
Application caching brings three advantages to applications:
- Offline browsing-users can use them when the application is offline
- Speed-cached resources are loaded faster
- Server Load Reduction-the browser will only download updated or changed resources from the server. <Html manifest = "http://www.w3school.com.cn/example/html5/html5_html_manifest.html.appcache"> <! -- Demo. apache --> <body> <p> open <a href = "http://www.w3school.com.cn/example/html5/html5_html_manifest.html" target = "_ blank"> This page </a>, browse it offline, and reload the page. Scripts and images on the page are still available. </P>
Each page with a specified manifest is cached when the user accesses it. If the manifest attribute is not specified, the page is not cached (unless the page is specified in the manifest file)
Please note that the manifest file needs to be configuredCorrect MIME-typeText/cache-manifest ". Must be configured on the web server.
The manifest file can be divided into three parts:
- Cache manifest-files listed under this title will be cached after the first download
- NETWORK-the files listed under this title need to be connected to the server and will not be cached
- FALLBACK-the files listed under this title specify the rollback page when the page cannot be accessed (such as the 404 page)
CACHE MANIFEST# 2012-02-21 v1.0.0/theme.css/logo.gif/main.jsNETWORK:login.aspFALLBACK:/html5/ /404.html
<input type="search" name="user_search" placeholder
="Search W3School"
/>