Basic use of canvas for html5 learning: div is in front of js; localStorage is stored in different locations based on the browser; application cache; placeholder attribute provides a tip (hint ), description of the expected value of the input field.

Source: Internet
Author: User

<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" />

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.