{"id":1943,"date":"2025-02-23T13:40:08","date_gmt":"2025-02-23T05:40:08","guid":{"rendered":"https:\/\/www.laixuexila.com\/?p=1943"},"modified":"2025-02-23T13:40:08","modified_gmt":"2025-02-23T05:40:08","slug":"html5-%e6%b5%8f%e8%a7%88%e5%99%a8%e6%94%af%e6%8c%81","status":"publish","type":"post","link":"https:\/\/www.laixuexila.com\/index.php\/2025\/02\/23\/html5-%e6%b5%8f%e8%a7%88%e5%99%a8%e6%94%af%e6%8c%81\/","title":{"rendered":"HTML5\u00a0\u6d4f\u89c8\u5668\u652f\u6301"},"content":{"rendered":"\n<p>HTML5 \u63d0\u4f9b\u4e86\u8bb8\u591a\u65b0\u7684\u529f\u80fd\u548c\u6807\u7b7e\uff0c\u4f46\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u5bf9 HTML5 \u7684\u652f\u6301\u7a0b\u5ea6\u4e0d\u540c\uff0c\u56e0\u6b64\u4e86\u89e3 HTML5 \u5728\u5404\u5927\u6d4f\u89c8\u5668\u4e2d\u7684\u652f\u6301\u60c5\u51b5\u662f\u5f88\u91cd\u8981\u7684\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u89c1\u7684 HTML5 \u529f\u80fd\u7684\u6d4f\u89c8\u5668\u652f\u6301\u60c5\u51b5\u6982\u8ff0\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u6d4f\u89c8\u5668\u5bf9 HTML5 \u7684\u652f\u6301<\/strong><\/h3>\n\n\n\n<p>HTML5 \u7684\u652f\u6301\u4e3b\u8981\u4f53\u73b0\u5728\u4ee5\u4e0b\u51e0\u4e2a\u65b9\u9762\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u65b0\u6807\u7b7e<\/strong>\uff1a\u5982 <code>&lt;article><\/code>\u3001<code>&lt;section><\/code>\u3001<code>&lt;header><\/code>\u3001<code>&lt;footer><\/code> \u7b49\u8bed\u4e49\u5316\u6807\u7b7e\u3002<\/li>\n\n\n\n<li><strong>\u89c6\u9891\u548c\u97f3\u9891\u652f\u6301<\/strong>\uff1a\u5982 <code>&lt;audio><\/code> \u548c <code>&lt;video><\/code> \u6807\u7b7e\uff0c\u6d4f\u89c8\u5668\u5bf9\u8fd9\u4e9b\u6807\u7b7e\u7684\u652f\u6301\u60c5\u51b5\u4e0d\u540c\u3002<\/li>\n\n\n\n<li><strong>\u672c\u5730\u5b58\u50a8<\/strong>\uff1a\u5982 <code>localStorage<\/code> \u548c <code>sessionStorage<\/code>\uff0c\u8fd9\u4e9b API \u7684\u652f\u6301\u9700\u8981\u73b0\u4ee3\u6d4f\u89c8\u5668\u3002<\/li>\n\n\n\n<li><strong>Canvas \u548c WebGL<\/strong>\uff1a\u7528\u4e8e\u7ed8\u5236\u56fe\u5f62\u548c\u8fdb\u884c 2D\u30013D \u6e32\u67d3\u7684\u529f\u80fd\uff0c\u901a\u5e38\u73b0\u4ee3\u6d4f\u89c8\u5668\u90fd\u652f\u6301\u3002<\/li>\n\n\n\n<li><strong>CSS3 \u548c JavaScript<\/strong>\uff1aHTML5 \u4e5f\u6d89\u53ca CSS3 \u548c JavaScript API \u7684\u6539\u8fdb\uff0c\u5c24\u5176\u662f\u5bf9\u52a8\u753b\u3001\u8fc7\u6e21\u3001API \u652f\u6301\u7684\u589e\u5f3a\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u4e3b\u8981\u6d4f\u89c8\u5668\u7684 HTML5 \u652f\u6301\u60c5\u51b5<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Chrome<\/strong>\uff1aChrome \u6d4f\u89c8\u5668\u5bf9 HTML5 \u7684\u652f\u6301\u975e\u5e38\u597d\uff0c\u51e0\u4e4e\u6240\u6709\u65b0\u7279\u6027\u90fd\u80fd\u5f97\u5230\u652f\u6301\u3002\u8c37\u6b4c\u4f1a\u5b9a\u671f\u53d1\u5e03\u66f4\u65b0\uff0c\u786e\u4fdd HTML5 \u7279\u6027\u5c3d\u53ef\u80fd\u5f97\u5230\u6700\u597d\u7684\u652f\u6301\u3002<\/li>\n\n\n\n<li><strong>Firefox<\/strong>\uff1aFirefox \u4e5f\u6709\u5f88\u5f3a\u7684 HTML5 \u652f\u6301\uff0c\u7279\u522b\u662f\u5f00\u6e90\u793e\u533a\u652f\u6301\uff0c\u8bb8\u591a HTML5 API \u548c\u529f\u80fd\u90fd\u80fd\u987a\u5229\u8fd0\u884c\u3002<\/li>\n\n\n\n<li><strong>Safari<\/strong>\uff1aSafari \u5bf9 HTML5 \u7684\u652f\u6301\u4e5f\u76f8\u5f53\u5168\u9762\uff0c\u5c24\u5176\u662f\u5728 iOS \u8bbe\u5907\u4e0a\u7684\u6d4f\u89c8\u5668\uff0c\u652f\u6301\u4e86\u8bb8\u591a\u91cd\u8981\u7684 HTML5 \u7279\u6027\u3002<\/li>\n\n\n\n<li><strong>Internet Explorer<\/strong>\uff1aIE9 \u53ca\u4ee5\u4e0a\u7248\u672c\u5f00\u59cb\u652f\u6301 HTML5\uff0c\u5c24\u5176\u662f\u5bf9\u65b0\u6807\u7b7e\u548c\u89c6\u9891\u7684\u652f\u6301\u6709\u6240\u6539\u8fdb\uff0c\u4f46\u4ecd\u7136\u7f3a\u4e4f\u5bf9\u4e00\u4e9b\u73b0\u4ee3 API \u7684\u652f\u6301\uff0c\u5982 WebSockets \u548c Web Workers\u3002IE10 \u53ca\u4ee5\u4e0a\u5bf9 HTML5 \u652f\u6301\u66f4\u597d\uff0c\u4f46\u7531\u4e8e IE \u7684\u9010\u6b65\u6dd8\u6c70\uff0c\u5f88\u591a\u65b0\u529f\u80fd\u5728 IE \u4e2d\u8868\u73b0\u5e76\u4e0d\u7406\u60f3\u3002<\/li>\n\n\n\n<li><strong>Edge<\/strong>\uff1a\u5fae\u8f6f Edge \u6d4f\u89c8\u5668\u57fa\u4e8e Chromium\uff0c\u5177\u5907\u4e0e Chrome \u76f8\u4f3c\u7684 HTML5 \u652f\u6301\uff0c\u57fa\u672c\u652f\u6301\u73b0\u4ee3 HTML5 \u7684\u6240\u6709\u7279\u6027\u3002<\/li>\n\n\n\n<li><strong>Opera<\/strong>\uff1aOpera \u6d4f\u89c8\u5668\u4e5f\u5f88\u5feb\u5b9e\u73b0\u4e86\u5bf9 HTML5 \u7684\u5168\u9762\u652f\u6301\uff0c\u5c24\u5176\u662f\u5728\u65b0\u7248\u672c\u4e2d\uff0c\u5bf9\u5927\u90e8\u5206 HTML5 \u529f\u80fd\u6709\u5f88\u597d\u7684\u652f\u6301\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>HTML5 \u6d4f\u89c8\u5668\u652f\u6301\u5de5\u5177<\/strong><\/h3>\n\n\n\n<p>\u4e3a\u4e86\u5e2e\u52a9\u5f00\u53d1\u8005\u67e5\u770b\u5404\u4e2a\u6d4f\u89c8\u5668\u5bf9 HTML5 \u7279\u6027\u7684\u652f\u6301\u60c5\u51b5\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u5de5\u5177\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Can I Use<\/strong>\uff1a<a href=\"https:\/\/caniuse.com\/\">https:\/\/caniuse.com\/<\/a> \u8fd9\u4e2a\u7f51\u7ad9\u63d0\u4f9b\u4e86\u8be6\u7ec6\u7684 HTML5 \u7279\u6027\u5728\u5404\u5927\u6d4f\u89c8\u5668\u7684\u652f\u6301\u60c5\u51b5\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u51b3\u5b9a\u662f\u5426\u4f7f\u7528\u67d0\u4e2a\u7279\u6027\u3002<\/li>\n\n\n\n<li><strong>HTML5 Please<\/strong>\uff1a<a href=\"https:\/\/html5please.com\/\">https:\/\/html5please.com\/<\/a> \u8fd9\u662f\u4e00\u4e2a\u5de5\u5177\uff0c\u7528\u6765\u5e2e\u52a9\u5f00\u53d1\u8005\u9009\u62e9\u662f\u5426\u5e94\u8be5\u4f7f\u7528\u67d0\u4e2a HTML5 \u7279\u6027\uff0c\u5e76\u63d0\u4f9b\u9488\u5bf9\u65e7\u7248\u6d4f\u89c8\u5668\u7684\u56de\u9000\u65b9\u6848\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u6ce8\u610f\u4e8b\u9879<\/strong><\/h3>\n\n\n\n<p>\u5728\u4f7f\u7528 HTML5 \u65f6\uff0c\u53ef\u80fd\u4f1a\u9047\u5230\u4e00\u4e9b\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u95ee\u9898\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u6280\u5de7\u6765\u786e\u4fdd\u9875\u9762\u5728\u4e0d\u540c\u6d4f\u89c8\u5668\u4e0a\u7684\u517c\u5bb9\u6027\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7279\u6027\u68c0\u6d4b<\/strong>\uff1a\u5728 JavaScript \u4e2d\uff0c\u4f7f\u7528 <code>Modernizr<\/code> \u7b49\u5e93\u6765\u68c0\u6d4b\u6d4f\u89c8\u5668\u662f\u5426\u652f\u6301\u67d0\u4e2a HTML5 \u7279\u6027\u3002\u8fd9\u6837\u53ef\u4ee5\u52a8\u6001\u52a0\u8f7d\u4e0d\u540c\u7684\u4ee3\u7801\uff0c\u4ee5\u786e\u4fdd\u6d4f\u89c8\u5668\u517c\u5bb9\u6027\u3002<\/li>\n\n\n\n<li><strong>Polyfill<\/strong>\uff1a\u5bf9\u4e8e\u4e00\u4e9b\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u7684 HTML5 \u7279\u6027\uff0c\u53ef\u4ee5\u4f7f\u7528 Polyfill\uff08\u517c\u5bb9\u5c42\uff09\uff0c\u5b83\u901a\u8fc7 JavaScript \u5b9e\u73b0\u8fd9\u4e9b\u4e0d\u88ab\u652f\u6301\u7684\u529f\u80fd\u3002\u4f8b\u5982\uff0c<code>html5shiv<\/code> \u5c31\u662f\u4e00\u4e2a\u7528\u4e8e\u652f\u6301 IE 8 \u53ca\u4ee5\u4e0b\u7248\u672c\u7684 HTML5 \u6807\u7b7e\u7684 Polyfill\u3002<\/li>\n\n\n\n<li><strong>CSS \u524d\u7f00<\/strong>\uff1a\u67d0\u4e9b CSS3 \u548c HTML5 \u7279\u6027\uff08\u5982\u52a8\u753b\u3001\u8fc7\u6e21\u7b49\uff09\u5728\u4e0d\u540c\u6d4f\u89c8\u5668\u4e2d\u53ef\u80fd\u9700\u8981\u52a0\u4e0a\u5382\u5546\u524d\u7f00\uff08\u4f8b\u5982 <code>-webkit-<\/code>\u3001<code>-moz-<\/code> \u7b49\uff09\u3002\u53ef\u4ee5\u4f7f\u7528 Autoprefixer \u7b49\u5de5\u5177\u81ea\u52a8\u4e3a CSS \u6dfb\u52a0\u5408\u9002\u7684\u524d\u7f00\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">\u5c0f\u7ed3<\/h3>\n\n\n\n<p>HTML5 \u7684\u63a8\u51fa\u6781\u5927\u4e30\u5bcc\u4e86\u7f51\u9875\u5f00\u53d1\u7684\u529f\u80fd\uff0c\u5e2e\u52a9\u5f00\u53d1\u8005\u6784\u5efa\u66f4\u5f3a\u5927\u3001\u4e92\u52a8\u7684\u7f51\u9875\u5e94\u7528\u3002\u968f\u7740\u6d4f\u89c8\u5668\u9010\u6e10\u66f4\u65b0\uff0c\u5b83\u4eec\u5bf9 HTML5 \u7684\u652f\u6301\u8d8a\u6765\u8d8a\u5b8c\u5584\u3002\u4e3a\u4e86\u786e\u4fdd\u517c\u5bb9\u6027\uff0c\u5f00\u53d1\u8005\u5e94\u5173\u6ce8\u5404\u5927\u6d4f\u89c8\u5668\u7684\u652f\u6301\u60c5\u51b5\uff0c\u4f7f\u7528\u5408\u9002\u7684\u5de5\u5177\u548c\u6280\u5de7\u6765\u89e3\u51b3\u517c\u5bb9\u6027\u95ee\u9898\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u9644\uff1a\u4e0b\u9762\u4e3a\u6bcf\u4e2a HTML5 \u7279\u6027\u548c\u6d4f\u89c8\u5668\u652f\u6301\u60c5\u51b5\u6dfb\u52a0\u4e00\u4e9b\u5b9e\u4f8b\uff0c\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. <strong>\u65b0\u6807\u7b7e\u7684\u652f\u6301<\/strong><\/h3>\n\n\n\n<p>HTML5 \u5f15\u5165\u4e86\u4e00\u4e9b\u65b0\u7684\u8bed\u4e49\u5316\u6807\u7b7e\uff0c\u5982 <code>&lt;article&gt;<\/code>\u3001<code>&lt;section&gt;<\/code>\u3001<code>&lt;header&gt;<\/code> \u7b49\uff0c\u8fd9\u4e9b\u6807\u7b7e\u4f7f\u5f97\u7f51\u9875\u7ed3\u6784\u66f4\u6e05\u6670\u4e14\u6613\u4e8e\u7ef4\u62a4\u3002\u6211\u4eec\u6765\u770b\u770b\u8fd9\u4e9b\u6807\u7b7e\u7684\u57fa\u672c\u4f7f\u7528\uff1a<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u4f7f\u7528 HTML5 \u65b0\u6807\u7b7e<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;HTML5 \u65b0\u6807\u7b7e\u793a\u4f8b&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;header&gt;\n        &lt;h1&gt;\u6b22\u8fce\u8bbf\u95ee\u6211\u7684\u535a\u5ba2&lt;\/h1&gt;\n        &lt;nav&gt;\n            &lt;ul&gt;\n                &lt;li&gt;&lt;a href=\"#home\"&gt;\u9996\u9875&lt;\/a&gt;&lt;\/li&gt;\n                &lt;li&gt;&lt;a href=\"#about\"&gt;\u5173\u4e8e&lt;\/a&gt;&lt;\/li&gt;\n                &lt;li&gt;&lt;a href=\"#contact\"&gt;\u8054\u7cfb&lt;\/a&gt;&lt;\/li&gt;\n            &lt;\/ul&gt;\n        &lt;\/nav&gt;\n    &lt;\/header&gt;\n\n    &lt;section&gt;\n        &lt;h2&gt;\u6700\u65b0\u6587\u7ae0&lt;\/h2&gt;\n        &lt;article&gt;\n            &lt;h3&gt;\u5982\u4f55\u5b66\u4e60 HTML5&lt;\/h3&gt;\n            &lt;p&gt;HTML5 \u662f\u5f53\u524d\u7f51\u9875\u5f00\u53d1\u7684\u6838\u5fc3\u6280\u672f\uff0c\u4e86\u89e3 HTML5 \u53ef\u4ee5\u8ba9\u4f60\u521b\u5efa\u66f4\u73b0\u4ee3\u3001\u66f4\u6709\u4e92\u52a8\u6027\u7684\u7f51\u9875\u3002&lt;\/p&gt;\n        &lt;\/article&gt;\n        &lt;article&gt;\n            &lt;h3&gt;CSS3 \u7684\u65b0\u7279\u6027&lt;\/h3&gt;\n            &lt;p&gt;CSS3 \u5e26\u6765\u4e86\u8bb8\u591a\u65b0\u7279\u6027\uff0c\u6bd4\u5982\u52a8\u753b\u3001\u8fc7\u6e21\u548c\u54cd\u5e94\u5f0f\u8bbe\u8ba1\u3002&lt;\/p&gt;\n        &lt;\/article&gt;\n    &lt;\/section&gt;\n\n    &lt;footer&gt;\n        &lt;p&gt;&amp;copy; 2025 \u6211\u7684\u535a\u5ba2. \u4fdd\u7559\u6240\u6709\u6743\u5229\u3002&lt;\/p&gt;\n    &lt;\/footer&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. <strong>\u97f3\u9891\u548c\u89c6\u9891\u652f\u6301<\/strong><\/h3>\n\n\n\n<p>HTML5 \u63d0\u4f9b\u4e86 <code>&lt;audio&gt;<\/code> \u548c <code>&lt;video&gt;<\/code> \u6807\u7b7e\uff0c\u4f7f\u5f97\u5728\u7f51\u9875\u4e2d\u5d4c\u5165\u591a\u5a92\u4f53\u5185\u5bb9\u53d8\u5f97\u66f4\u52a0\u7b80\u5355\u3002\u73b0\u4ee3\u6d4f\u89c8\u5668\u652f\u6301\u8fd9\u4e9b\u6807\u7b7e\uff0c\u4f46\u6709\u4e9b\u65e7\u6d4f\u89c8\u5668\u53ef\u80fd\u4e0d\u652f\u6301\uff0c\u5c24\u5176\u662f Internet Explorer 9 \u53ca\u4ee5\u4e0b\u7248\u672c\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u4f7f\u7528 <code>&lt;audio&gt;<\/code> \u548c <code>&lt;video&gt;<\/code> \u6807\u7b7e<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;\u97f3\u9891\u548c\u89c6\u9891\u793a\u4f8b&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;HTML5 \u97f3\u9891\u793a\u4f8b&lt;\/h1&gt;\n    &lt;audio controls&gt;\n        &lt;source src=\"audio.mp3\" type=\"audio\/mp3\" \/&gt;\n        \u4f60\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u97f3\u9891\u5143\u7d20\u3002\n    &lt;\/audio&gt;\n\n    &lt;h1&gt;HTML5 \u89c6\u9891\u793a\u4f8b&lt;\/h1&gt;\n    &lt;video width=\"320\" height=\"240\" controls&gt;\n        &lt;source src=\"video.mp4\" type=\"video\/mp4\" \/&gt;\n        \u4f60\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u89c6\u9891\u6807\u7b7e\u3002\n    &lt;\/video&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6d4f\u89c8\u5668\u517c\u5bb9\u6027<\/strong>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5728\u73b0\u4ee3\u6d4f\u89c8\u5668\u4e2d\uff0c\u5982 Chrome\u3001Firefox\u3001Safari \u548c Edge\uff0c\u97f3\u9891\u548c\u89c6\u9891\u6807\u7b7e\u80fd\u5f88\u597d\u5730\u5de5\u4f5c\u3002<\/li>\n\n\n\n<li>IE9 \u53ca\u4ee5\u4e0b\u7248\u672c\u9700\u8981\u989d\u5916\u7684\u63d2\u4ef6\u652f\u6301\uff0c\u5982 Flash\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">3. <strong>Canvas \u652f\u6301<\/strong><\/h3>\n\n\n\n<p>HTML5 <code>&lt;canvas&gt;<\/code> \u5143\u7d20\u5141\u8bb8\u5728\u7f51\u9875\u4e0a\u7ed8\u5236\u56fe\u5f62\u3002\u73b0\u4ee3\u6d4f\u89c8\u5668\u90fd\u652f\u6301\u8fd9\u4e2a\u7279\u6027\uff0c\u4f46\u5bf9\u4e8e\u8f83\u8001\u7684\u6d4f\u89c8\u5668\uff08\u5982 Internet Explorer 8 \u53ca\u4ee5\u4e0b\uff09\uff0c\u9700\u8981\u901a\u8fc7 Polyfill \u5b9e\u73b0\u652f\u6301\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u4f7f\u7528 <code>&lt;canvas&gt;<\/code> \u7ed8\u5236\u56fe\u5f62<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Canvas \u793a\u4f8b&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;HTML5 Canvas \u793a\u4f8b&lt;\/h1&gt;\n    &lt;canvas id=\"myCanvas\" width=\"200\" height=\"200\" style=\"border:1px solid #000000;\"&gt;\n        \u4f60\u7684\u6d4f\u89c8\u5668\u4e0d\u652f\u6301 Canvas\u3002\n    &lt;\/canvas&gt;\n    &lt;script&gt;\n        var canvas = document.getElementById(\"myCanvas\");\n        var ctx = canvas.getContext(\"2d\");\n\n        \/\/ \u7ed8\u5236\u4e00\u4e2a\u7ea2\u8272\u77e9\u5f62\n        ctx.fillStyle = \"red\";\n        ctx.fillRect(50, 50, 100, 100);\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. <strong>\u672c\u5730\u5b58\u50a8\u652f\u6301<\/strong><\/h3>\n\n\n\n<p>HTML5 \u5f15\u5165\u4e86 <code>localStorage<\/code> \u548c <code>sessionStorage<\/code>\uff0c\u5141\u8bb8\u7f51\u9875\u5728\u672c\u5730\u5b58\u50a8\u6570\u636e\u3002<code>localStorage<\/code> \u4fdd\u5b58\u7684\u6570\u636e\u5728\u6d4f\u89c8\u5668\u5173\u95ed\u540e\u4ecd\u7136\u5b58\u5728\uff0c\u800c <code>sessionStorage<\/code> \u4ec5\u5728\u5f53\u524d\u4f1a\u8bdd\u4e2d\u6709\u6548\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u4f7f\u7528 <code>localStorage<\/code> \u5b58\u50a8\u6570\u636e<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;LocalStorage \u793a\u4f8b&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;HTML5 LocalStorage \u793a\u4f8b&lt;\/h1&gt;\n    &lt;button onclick=\"storeData()\"&gt;\u5b58\u50a8\u6570\u636e&lt;\/button&gt;\n    &lt;button onclick=\"getData()\"&gt;\u83b7\u53d6\u6570\u636e&lt;\/button&gt;\n    &lt;button onclick=\"clearData()\"&gt;\u6e05\u9664\u6570\u636e&lt;\/button&gt;\n\n    &lt;script&gt;\n        function storeData() {\n            localStorage.setItem('username', 'JohnDoe');\n            alert('\u6570\u636e\u5df2\u5b58\u50a8\uff01');\n        }\n\n        function getData() {\n            var username = localStorage.getItem('username');\n            alert('\u5b58\u50a8\u7684\u6570\u636e\u662f: ' + username);\n        }\n\n        function clearData() {\n            localStorage.removeItem('username');\n            alert('\u6570\u636e\u5df2\u6e05\u9664\uff01');\n        }\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u6d4f\u89c8\u5668\u517c\u5bb9\u6027<\/strong>\uff1a<\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>localStorage<\/code> \u548c <code>sessionStorage<\/code> \u5728\u73b0\u4ee3\u6d4f\u89c8\u5668\uff08Chrome\u3001Firefox\u3001Safari\u3001Edge\uff09\u4e2d\u90fd\u5f97\u5230\u4e86\u5f88\u597d\u7684\u652f\u6301\u3002<\/li>\n\n\n\n<li>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cInternet Explorer 8 \u53ca\u4ee5\u4e0b\u7248\u672c\u4e0d\u652f\u6301\u8fd9\u4e9b API\u3002<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">5. <strong>\u5730\u7406\u4f4d\u7f6e\u652f\u6301\uff08Geolocation API\uff09<\/strong><\/h3>\n\n\n\n<p>HTML5 \u63d0\u4f9b\u4e86 Geolocation API\uff0c\u5141\u8bb8\u7f51\u9875\u83b7\u53d6\u7528\u6237\u7684\u4f4d\u7f6e\u4fe1\u606f\u3002\u8fd9\u5bf9\u4e8e\u5b9a\u4f4d\u670d\u52a1\u3001\u5730\u56fe\u5e94\u7528\u7b49\u975e\u5e38\u6709\u7528\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u793a\u4f8b\uff1a\u4f7f\u7528 Geolocation API \u83b7\u53d6\u7528\u6237\u4f4d\u7f6e<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html&gt;\n&lt;html&gt;\n&lt;head&gt;\n    &lt;title&gt;Geolocation \u793a\u4f8b&lt;\/title&gt;\n&lt;\/head&gt;\n&lt;body&gt;\n    &lt;h1&gt;\u83b7\u53d6\u7528\u6237\u4f4d\u7f6e&lt;\/h1&gt;\n    &lt;button onclick=\"getLocation()\"&gt;\u83b7\u53d6\u4f4d\u7f6e&lt;\/button&gt;\n    &lt;p id=\"location\"&gt;&lt;\/p&gt;\n\n    &lt;script&gt;\n        function getLocation() {\n            if (navigator.geolocation) {\n                navigator.geolocation.getCurrentPosition(showPosition, showError);\n            } else {\n                alert(\"\u6d4f\u89c8\u5668\u4e0d\u652f\u6301\u5730\u7406\u4f4d\u7f6e\u670d\u52a1\u3002\");\n            }\n        }\n\n        function showPosition(position) {\n            var latitude = position.coords.latitude;\n            var longitude = position.coords.longitude;\n            document.getElementById(\"location\").innerHTML = \"\u7eac\u5ea6: \" + latitude + \"&lt;br&gt;\u7ecf\u5ea6: \" + longitude;\n        }\n\n        function showError(error) {\n            switch (error.code) {\n                case error.PERMISSION_DENIED:\n                    alert(\"\u7528\u6237\u62d2\u7edd\u4e86\u4f4d\u7f6e\u8bf7\u6c42.\");\n                    break;\n                case error.POSITION_UNAVAILABLE:\n                    alert(\"\u65e0\u6cd5\u83b7\u53d6\u4f4d\u7f6e.\");\n                    break;\n                case error.TIMEOUT:\n                    alert(\"\u8bf7\u6c42\u8d85\u65f6.\");\n                    break;\n                case error.UNKNOWN_ERROR:\n                    alert(\"\u53d1\u751f\u672a\u77e5\u9519\u8bef.\");\n                    break;\n            }\n        }\n    &lt;\/script&gt;\n&lt;\/body&gt;\n&lt;\/html&gt;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>HTML5 \u63d0\u4f9b\u4e86\u8bb8\u591a\u65b0\u7684\u529f\u80fd\u548c\u6807\u7b7e\uff0c\u4f46\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u5bf9 HTML5 \u7684\u652f\u6301\u7a0b\u5ea6\u4e0d\u540c\uff0c\u56e0\u6b64\u4e86\u89e3 HTML5 \u5728\u5404 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[75],"tags":[],"class_list":["post-1943","post","type-post","status-publish","format-standard","hentry","category-html5"],"_links":{"self":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1943","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/comments?post=1943"}],"version-history":[{"count":1,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1943\/revisions"}],"predecessor-version":[{"id":1944,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/posts\/1943\/revisions\/1944"}],"wp:attachment":[{"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/media?parent=1943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/categories?post=1943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.laixuexila.com\/index.php\/wp-json\/wp\/v2\/tags?post=1943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}