{"id":52785,"date":"2025-08-11T19:19:31","date_gmt":"2025-08-11T11:19:31","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/52785.html"},"modified":"2025-08-11T19:19:31","modified_gmt":"2025-08-11T11:19:31","slug":"%e3%80%90web%e5%ae%89%e5%85%a8%e3%80%91html5%e5%ae%89%e5%85%a8%e5%9f%ba%e7%a1%80%e6%8c%87%e5%8d%97%ef%bc%9a%e4%bb%8e%e5%85%a5%e9%97%a8%e5%88%b0%e9%81%bf%e5%9d%91-%e5%b0%8f%e7%99%bd","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/52785.html","title":{"rendered":"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c"},"content":{"rendered":"<\/p>\n<h4>\u6587\u7ae0\u76ee\u5f55<\/h4>\n<ul>\n<li>\u524d\u8a00<\/li>\n<li>1 \u65b0\u6807\u7b7e\u7684XSS<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fXSS&#xff1f;<\/li>\n<li>\u98ce\u9669\u573a\u666f&#xff1a;\u65b0\u6807\u7b7e\u5982\u4f55\u88ab\u5229\u7528&#xff1f;<\/li>\n<li>\u4e3a\u4ec0\u4e48\u4f1a\u6709\u8fd9\u6837\u7684\u98ce\u9669&#xff1f;<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>2 iframe \u7684 sandbox \u5c5e\u6027<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fiframe&#xff1f;<\/li>\n<li>sandbox\u5c5e\u6027&#xff1a;\u7ed9iframe\u52a0\u4e2a\u201c\u5b89\u5168\u7f69\u201d<\/li>\n<li>\u6700\u5371\u9669\u7684\u7ec4\u5408&#xff1a;allow-scripts &#043; allow-same-origin<\/li>\n<li>\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;\u6b63\u786e\u4f7f\u7528sandbox<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>3 noreferrer \u5c5e\u6027<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fReferer&#xff1f;<\/li>\n<li>noreferrer&#xff1a;\u9690\u85cf\u4f60\u7684\u201c\u6765\u6e90\u201d<\/li>\n<li>\u6ce8\u610f&#xff1a;noreferrer\u548cnoopener\u7684\u533a\u522b<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>4 postMessage&#xff1a;\u8de8\u7a97\u53e3\u901a\u4fe1\u7684\u201c\u5b89\u5168\u7ef3\u201d<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fpostMessage&#xff1f;<\/li>\n<li>postMessage\u7684\u5b89\u5168\u98ce\u9669<\/li>\n<li>\n<ul>\n<li>\u98ce\u96691&#xff1a;\u4e0d\u9a8c\u8bc1\u63a5\u6536\u7a97\u53e3\u7684\u6765\u6e90<\/li>\n<li>\u98ce\u96692&#xff1a;\u6d88\u606f\u5185\u5bb9\u672a\u8fc7\u6ee4&#xff0c;\u5bfc\u81f4XSS<\/li>\n<\/ul>\n<\/li>\n<li>\u5982\u4f55\u5b89\u5168\u4f7f\u7528postMessage&#xff1f;<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>5 WebStorage&#xff1a;\u672c\u5730\u5b58\u50a8\u7684\u201c\u5b89\u5168\u5751\u201d<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fWebStorage&#xff1f;<\/li>\n<li>WebStorage\u7684\u4f7f\u7528\u65b9\u6cd5<\/li>\n<li>WebStorage\u7684\u5b89\u5168\u98ce\u9669<\/li>\n<li>\u4e3e\u4e2a\u5371\u9669\u7684\u4f8b\u5b50<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>6 \u4f7f\u7528postMessage\u5b9e\u73b0\u8de8\u57df&#xff1a;\u76ee\u6807\u6e90\u4e0d\u80fd\u201c\u5077\u61d2\u201d<\/li>\n<li>\n<ul>\n<li>\u8de8\u57df\u901a\u4fe1\u7684\u5e38\u89c1\u9700\u6c42<\/li>\n<li>\u9519\u8bef\u7528\u6cd5&#xff1a;\u56fe\u7701\u4e8b\u7528\u201c*\u201d<\/li>\n<li>\u6b63\u786e\u7528\u6cd5&#xff1a;\u660e\u786e\u6307\u5b9a\u76ee\u6807\u6e90<\/li>\n<li>\u4e3a\u4ec0\u4e48\u76ee\u6807\u6e90\u5fc5\u987b\u4e25\u683c\u6307\u5b9a&#xff1f;<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>7 \u63a5\u53d7message&#xff1a;\u5fc5\u987b\u6821\u9a8c\u6570\u636e\u6765\u6e90<\/li>\n<li>\n<ul>\n<li>\u63a5\u6536\u6d88\u606f\u7684\u201c\u4fe1\u4efb\u5371\u673a\u201d<\/li>\n<li>\u9519\u8bef\u7528\u6cd5&#xff1a;\u6765\u8005\u4e0d\u62d2<\/li>\n<li>\u6b63\u786e\u7528\u6cd5&#xff1a;\u5148\u9a8c\u660e\u6b63\u8eab<\/li>\n<li>\u989d\u5916\u63d0\u9192&#xff1a;\u6821\u9a8c\u6d88\u606f\u5185\u5bb9\u683c\u5f0f<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>8 \u7981\u6b62\u4f7f\u7528Web SQL\u6570\u636e\u5e93<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662fWeb SQL\u6570\u636e\u5e93&#xff1f;<\/li>\n<li>Web SQL\u6570\u636e\u5e93\u7684\u5b89\u5168\u98ce\u9669<\/li>\n<li>\u5982\u4f55\u68c0\u6d4b\u5e76\u907f\u514d\u4f7f\u7528&#xff1f;<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>9 \u9493\u9c7c\u98ce\u9669&#xff1a;window.open\u7684\u201c\u80cc\u540e\u4e00\u5200\u201d<\/li>\n<li>\n<ul>\n<li>\u4ec0\u4e48\u662f\u9493\u9c7c\u653b\u51fb&#xff1f;<\/li>\n<li>window.open\u7684\u98ce\u9669\u573a\u666f<\/li>\n<li>\u5982\u4f55\u9632\u5fa1\u9493\u9c7c\u98ce\u9669&#xff1f;<\/li>\n<li>\u989d\u5916\u63d0\u9192&#xff1a;\u8c28\u614e\u6253\u5f00\u4e0d\u53ef\u4fe1\u94fe\u63a5<\/li>\n<li>\u7ae0\u8282\u603b\u7ed3<\/li>\n<\/ul>\n<\/li>\n<li>\u5168\u6587\u603b\u7ed3<\/li>\n<\/ul>\n<h2>\u524d\u8a00<\/h2>\n<p>\u968f\u7740\u4e92\u8054\u7f51\u7684\u98de\u901f\u53d1\u5c55&#xff0c;HTML5\u4f5c\u4e3a\u6784\u5efaWeb\u9875\u9762\u7684\u6838\u5fc3\u6280\u672f&#xff0c;\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u2014\u2014\u4ece\u89c6\u9891\u64ad\u653e\u3001\u8de8\u57df\u901a\u4fe1\u5230\u672c\u5730\u6570\u636e\u5b58\u50a8&#xff0c;HTML5\u7684\u65b0\u7279\u6027\u8ba9\u7f51\u9875\u4e0d\u518d\u5c40\u9650\u4e8e\u7b80\u5355\u7684\u6587\u5b57\u548c\u56fe\u7247\u5c55\u793a\u3002\u4f46\u8fd9\u4e9b\u5f3a\u5927\u7684\u529f\u80fd\u5728\u4fbf\u5229\u6211\u4eec\u7684\u540c\u65f6&#xff0c;\u4e5f\u57cb\u4e0b\u4e86\u4e0d\u5c11\u5b89\u5168\u9690\u60a3\u3002<\/p>\n<p>HTML5\u7684\u5b89\u5168\u98ce\u9669\u5c31\u85cf\u5728\u65e5\u5e38\u5f00\u53d1\u7684\u7ec6\u8282\u91cc&#xff1a;\u4e00\u4e2a\u672a\u52a0\u9650\u5236\u7684iframe\u3001\u4e00\u6bb5\u6ca1\u505a\u6821\u9a8c\u7684\u8de8\u57df\u6d88\u606f\u3001\u4e00\u4e2a\u968f\u610f\u4f7f\u7528\u7684\u672c\u5730\u5b58\u50a8\u2026\u2026\u7a0d\u6709\u4e0d\u614e&#xff0c;\u5c31\u53ef\u80fd\u88ab\u653b\u51fb\u8005\u5229\u7528&#xff0c;\u5bfc\u81f4\u7528\u6237\u4fe1\u606f\u6cc4\u9732\u3001\u7f51\u9875\u88ab\u7be1\u6539\u751a\u81f3\u670d\u52a1\u5668\u88ab\u653b\u51fb\u3002<\/p>\n<p>\u672c\u6587\u4e13\u4e3a\u5b89\u5168\u5c0f\u767d\u6253\u9020&#xff0c;\u5c06\u7528\u901a\u4fd7\u6613\u61c2\u7684\u8bed\u8a00\u62c6\u89e3HTML5\u4e2d\u6700\u5e38\u89c1\u76849\u7c7b\u5b89\u5168\u98ce\u9669&#xff0c;\u5305\u62ec\u8de8\u7ad9\u811a\u672c\u653b\u51fb&#xff08;XSS&#xff09;\u3001iframe\u6ee5\u7528\u3001\u9690\u79c1\u6cc4\u9732\u3001\u9493\u9c7c\u653b\u51fb\u7b49&#xff0c;\u5e76\u9644\u4e0a\u5177\u4f53\u7684\u9632\u5fa1\u65b9\u6cd5\u3002\u65e0\u8bba\u4f60\u662f\u521a\u5165\u95e8\u7684\u5f00\u53d1\u8005&#xff0c;\u8fd8\u662f\u5bf9Web\u5b89\u5168\u611f\u5174\u8da3\u7684\u65b0\u624b&#xff0c;\u90fd\u80fd\u901a\u8fc7\u672c\u6587\u5feb\u901f\u638c\u63e1HTML5\u5b89\u5168\u7684\u6838\u5fc3\u8981\u70b9&#xff0c;\u907f\u5f00\u5e38\u89c1\u201c\u5751\u70b9\u201d&#xff0c;\u8ba9\u4f60\u7684\u7f51\u9875\u66f4\u5b89\u5168\u3002<\/p>\n<h2>1 \u65b0\u6807\u7b7e\u7684XSS<\/h2>\n<h3>\u4ec0\u4e48\u662fXSS&#xff1f;<\/h3>\n<p>\u5728\u8bb2HTML5\u65b0\u6807\u7b7e\u7684\u5b89\u5168\u98ce\u9669\u524d&#xff0c;\u6211\u4eec\u5148\u641e\u61c2\u4e00\u4e2a\u57fa\u7840\u6982\u5ff5&#xff1a;XSS&#xff08;Cross-Site Scripting&#xff0c;\u8de8\u7ad9\u811a\u672c\u653b\u51fb&#xff09;\u3002\u7b80\u5355\u6765\u8bf4&#xff0c;XSS\u5c31\u662f\u653b\u51fb\u8005\u5728\u7f51\u9875\u4e2d\u63d2\u5165\u6076\u610f\u7684\u811a\u672c\u4ee3\u7801&#xff08;\u6bd4\u5982JavaScript&#xff09;&#xff0c;\u5f53\u7528\u6237\u8bbf\u95ee\u8fd9\u4e2a\u7f51\u9875\u65f6&#xff0c;\u811a\u672c\u4f1a\u81ea\u52a8\u6267\u884c&#xff0c;\u53ef\u80fd\u4f1a\u7a83\u53d6\u7528\u6237\u7684\u8d26\u53f7\u5bc6\u7801\u3001Cookie&#xff0c;\u751a\u81f3\u63a7\u5236\u7528\u6237\u7684\u6d4f\u89c8\u5668\u3002<\/p>\n<p>HTML5\u65b0\u589e\u4e86&lt;video&gt;&#xff08;\u89c6\u9891\u64ad\u653e&#xff09;\u548c&lt;audio&gt;&#xff08;\u97f3\u9891\u64ad\u653e&#xff09;\u7b49\u6807\u7b7e&#xff0c;\u8ba9\u7f51\u9875\u80fd\u76f4\u63a5\u5d4c\u5165\u97f3\u89c6\u9891\u5185\u5bb9&#xff0c;\u4f46\u5982\u679c\u4f7f\u7528\u4e0d\u5f53&#xff0c;\u8fd9\u4e9b\u6807\u7b7e\u4e5f\u53ef\u80fd\u6210\u4e3aXSS\u7684\u201c\u6e29\u5e8a\u201d\u3002<\/p>\n<h3>\u98ce\u9669\u573a\u666f&#xff1a;\u65b0\u6807\u7b7e\u5982\u4f55\u88ab\u5229\u7528&#xff1f;<\/h3>\n<p>&lt;video&gt;\u548c&lt;audio&gt;\u6807\u7b7e\u9700\u8981\u901a\u8fc7src\u5c5e\u6027\u52a0\u8f7d\u8fdc\u7a0b\u6216\u672c\u5730\u7684\u97f3\u89c6\u9891\u8d44\u6e90&#xff0c;\u540c\u65f6\u5b83\u4eec\u8fd8\u652f\u6301\u5f88\u591a\u201c\u4e8b\u4ef6\u5c5e\u6027\u201d\u2014\u2014\u6bd4\u5982\u89c6\u9891\u52a0\u8f7d\u5b8c\u6210\u65f6\u89e6\u53d1\u7684onloadedmetadata\u3001\u64ad\u653e\u8fdb\u5ea6\u53d8\u5316\u65f6\u89e6\u53d1\u7684ontimeupdate\u7b49\u3002\u5982\u679c\u8fd9\u4e9b\u4e8b\u4ef6\u5c5e\u6027\u88ab\u63d2\u5165\u4e86\u6076\u610f\u811a\u672c&#xff0c;\u5c31\u4f1a\u5bfc\u81f4XSS\u653b\u51fb\u3002<\/p>\n<p>\u4e3e\u51e0\u4e2a\u4f8b\u5b50&#xff1a;<\/p>\n<p><span class=\"token comment\">&lt;!&#8211; video\u6807\u7b7e\u7684\u4e8b\u4ef6\u5c5e\u6027\u88ab\u6ce8\u5165\u6076\u610f\u811a\u672c &#8211;&gt;<\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>video<\/span> <span class=\"token attr-name\">src<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>http:\/\/xxx.com\/video.mp4<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token attr-name\">onloadedmetadata<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>alert(&#039;\u4f60\u7684\u4fe1\u606f\u88ab\u7a83\u53d6\u4e86&#039;);<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token attr-name\">tabindex<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>0<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>video<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u5f53\u89c6\u9891\u52a0\u8f7d\u5b8c\u6210\u540e&#xff0c;onloadedmetadata\u91cc\u7684alert\u811a\u672c\u4f1a\u81ea\u52a8\u6267\u884c&#xff0c;\u8fd9\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u5f39\u7a97\u6f14\u793a&#xff0c;\u5b9e\u9645\u653b\u51fb\u4e2d\u53ef\u80fd\u4f1a\u6362\u6210\u7a83\u53d6Cookie\u7684\u4ee3\u7801\u3002<\/p>\n<p>\u518d\u6bd4\u5982\u97f3\u9891\u6807\u7b7e&#xff1a;<\/p>\n<p><span class=\"token comment\">&lt;!&#8211; audio\u6807\u7b7e\u52a0\u8f7d\u5931\u8d25\u65f6\u89e6\u53d1\u6076\u610f\u811a\u672c &#8211;&gt;<\/span><br \/>\n<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>audio<\/span> <span class=\"token attr-name\">src<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>\u65e0\u6548\u7684\u5730\u5740<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token special-attr\"><span class=\"token attr-name\">onerror<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span><span class=\"token value javascript language-javascript\"><span class=\"token function\">alert<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;XSS\u653b\u51fb\u6210\u529f&#039;<\/span><span class=\"token punctuation\">)<\/span><\/span><span class=\"token punctuation\">&#034;<\/span><\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u5f53src\u6307\u5411\u7684\u5730\u5740\u65e0\u6548\u65f6&#xff0c;\u6d4f\u89c8\u5668\u4f1a\u89e6\u53d1onerror\u4e8b\u4ef6&#xff0c;\u6b64\u65f6\u6076\u610f\u811a\u672c\u5c31\u4f1a\u6267\u884c\u3002<\/p>\n<p>\u8fd8\u6709&lt;video&gt;\u6807\u7b7e\u91cc\u7684&lt;source&gt;\u5b50\u6807\u7b7e&#xff08;\u7528\u4e8e\u6307\u5b9a\u89c6\u9891\u6e90&#xff09;&#xff0c;\u4e5f\u53ef\u80fd\u88ab\u5229\u7528&#xff1a;<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>video<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>source<\/span> <span class=\"token special-attr\"><span class=\"token attr-name\">onerror<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span><span class=\"token value javascript language-javascript\"><span class=\"token function\">alert<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#039;XSS&#039;<\/span><span class=\"token punctuation\">)<\/span><\/span><span class=\"token punctuation\">&#034;<\/span><\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>video<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u5982\u679c&lt;source&gt;\u52a0\u8f7d\u5931\u8d25&#xff0c;onerror\u91cc\u7684\u811a\u672c\u5c31\u4f1a\u8fd0\u884c\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u4f1a\u6709\u8fd9\u6837\u7684\u98ce\u9669&#xff1f;<\/h3>\n<p>\u672c\u8d28\u4e0a&#xff0c;\u662f\u56e0\u4e3a\u5f00\u53d1\u8005\u6ca1\u6709\u5bf9\u6807\u7b7e\u7684\u5c5e\u6027\u8fdb\u884c\u4e25\u683c\u8fc7\u6ee4\u3002\u6bd4\u5982&#xff0c;\u5f53\u7f51\u9875\u5141\u8bb8\u7528\u6237\u81ea\u5b9a\u4e49\u97f3\u89c6\u9891\u7684\u5730\u5740\u6216\u5c5e\u6027\u65f6&#xff0c;\u5982\u679c\u76f4\u63a5\u5c06\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9\u62fc\u63a5\u5230\u6807\u7b7e\u4e2d&#xff0c;\u653b\u51fb\u8005\u5c31\u53ef\u4ee5\u8d81\u673a\u63d2\u5165\u6076\u610f\u7684\u4e8b\u4ef6\u5c5e\u6027\u548c\u811a\u672c\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>HTML5\u7684&lt;video&gt;\u548c&lt;audio&gt;\u6807\u7b7e\u867d\u7136\u65b9\u4fbf\u4e86\u97f3\u89c6\u9891\u5c55\u793a&#xff0c;\u4f46\u5b83\u4eec\u7684\u4e8b\u4ef6\u5c5e\u6027&#xff08;\u5982onloadedmetadata\u3001onerror&#xff09;\u53ef\u80fd\u6210\u4e3aXSS\u653b\u51fb\u7684\u5165\u53e3\u3002\u9632\u5fa1\u7684\u6838\u5fc3\u5728\u4e8e&#xff1a;<\/p>\n<li>\u4e25\u683c\u8fc7\u6ee4\u7528\u6237\u8f93\u5165\u7684\u5185\u5bb9&#xff0c;\u5c24\u5176\u662f\u6807\u7b7e\u7684\u5c5e\u6027&#xff0c;\u907f\u514d\u76f4\u63a5\u62fc\u63a5\u672a\u7ecf\u5904\u7406\u7684\u7528\u6237\u8f93\u5165&#xff1b;<\/li>\n<li>\u7981\u7528\u4e0d\u5fc5\u8981\u7684\u4e8b\u4ef6\u5c5e\u6027&#xff0c;\u53ea\u4fdd\u7559\u529f\u80fd\u5fc5\u9700\u7684\u5c5e\u6027&#xff1b;<\/li>\n<li>\u5bf9\u52a0\u8f7d\u7684\u97f3\u89c6\u9891\u8d44\u6e90\u5730\u5740\u8fdb\u884c\u6821\u9a8c&#xff0c;\u786e\u4fdd\u6765\u6e90\u53ef\u4fe1&#xff08;\u6bd4\u5982\u53ea\u5141\u8bb8\u81ea\u5bb6\u670d\u52a1\u5668\u7684\u8d44\u6e90&#xff09;\u3002<\/li>\n<h2>2 iframe \u7684 sandbox \u5c5e\u6027<\/h2>\n<h3>\u4ec0\u4e48\u662fiframe&#xff1f;<\/h3>\n<p>iframe\u662fHTML\u4e2d\u4e00\u4e2a\u5e38\u7528\u7684\u6807\u7b7e&#xff0c;\u7b80\u5355\u8bf4\u5c31\u662f\u201c\u7f51\u9875\u4e2d\u7684\u7f51\u9875\u201d\u2014\u2014\u5b83\u53ef\u4ee5\u5728\u5f53\u524d\u9875\u9762\u4e2d\u5d4c\u5165\u53e6\u4e00\u4e2a\u7f51\u9875\u3002\u6bd4\u5982\u5f88\u591a\u7f51\u7ad9\u7684\u201c\u767b\u5f55\u6846\u201d\u201c\u5e7f\u544a\u5f39\u7a97\u201d&#xff0c;\u53ef\u80fd\u5c31\u662f\u7528iframe\u5d4c\u5165\u7684\u5176\u4ed6\u9875\u9762\u3002<\/p>\n<p>\u4f46\u5982\u679c\u5d4c\u5165\u7684\u9875\u9762\u662f\u4e0d\u53ef\u4fe1\u7684&#xff08;\u6bd4\u5982\u7b2c\u4e09\u65b9\u7f51\u7ad9\u7684\u5185\u5bb9&#xff09;&#xff0c;\u5c31\u53ef\u80fd\u6709\u98ce\u9669&#xff1a;\u6bd4\u5982\u5bf9\u65b9\u7684\u9875\u9762\u91cc\u6709\u6076\u610f\u811a\u672c&#xff0c;\u53ef\u80fd\u4f1a\u7a83\u53d6\u5f53\u524d\u9875\u9762\u7684\u4fe1\u606f&#xff0c;\u6216\u8005\u7be1\u6539\u9875\u9762\u5185\u5bb9\u3002\u8fd9\u65f6\u5019&#xff0c;sandbox\u5c5e\u6027\u5c31\u6d3e\u4e0a\u7528\u573a\u4e86\u3002<\/p>\n<h3>sandbox\u5c5e\u6027&#xff1a;\u7ed9iframe\u52a0\u4e2a\u201c\u5b89\u5168\u7f69\u201d<\/h3>\n<p>sandbox\u662fiframe\u7684\u4e00\u4e2a\u5b89\u5168\u5c5e\u6027&#xff0c;\u5c31\u50cf\u7ed9\u5d4c\u5165\u7684\u9875\u9762\u52a0\u4e86\u4e00\u4e2a\u201c\u9694\u79bb\u7f69\u201d&#xff0c;\u53ef\u4ee5\u9650\u5236\u5b83\u7684\u529f\u80fd&#xff0c;\u9632\u6b62\u5b83\u641e\u7834\u574f\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u8bbe\u7f6e\u4e0d\u540c\u7684\u53c2\u6570&#xff0c;\u51b3\u5b9a\u5141\u8bb8\u6216\u7981\u6b62\u5d4c\u5165\u9875\u9762\u505a\u54ea\u4e9b\u4e8b\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u51e0\u4e2a\u5e38\u7528\u7684sandbox\u53c2\u6570&#xff0c;\u7528\u901a\u4fd7\u7684\u8bdd\u89e3\u91ca\u4e00\u4e0b&#xff1a;<\/p>\n<ul>\n<li>allow-top-navigation&#xff1a;\u5141\u8bb8\u5d4c\u5165\u7684\u9875\u9762\u201c\u8df3\u8f6c\u5230\u9876\u5c42\u9875\u9762\u201d\u3002\u6bd4\u5982\u5d4c\u5165\u7684\u9875\u9762\u6709\u4e2a\u6309\u94ae&#xff0c;\u70b9\u51fb\u540e\u8ba9\u6574\u4e2a\u6d4f\u89c8\u5668\u8df3\u8f6c\u5230\u53e6\u4e00\u4e2a\u7f51\u5740&#xff0c;\u8fd9\u4e2a\u53c2\u6570\u5c31\u63a7\u5236\u662f\u5426\u5141\u8bb8\u8fd9\u79cd\u64cd\u4f5c&#xff1b;<\/li>\n<li>allow-scripts&#xff1a;\u5141\u8bb8\u5d4c\u5165\u7684\u9875\u9762\u8fd0\u884cJavaScript\u811a\u672c\u3002\u5982\u679c\u4e0d\u8bbe\u7f6e\u8fd9\u4e2a\u53c2\u6570&#xff0c;\u5d4c\u5165\u9875\u9762\u91cc\u7684\u6240\u6709\u811a\u672c\u90fd\u4f1a\u88ab\u7981\u7528&#xff1b;<\/li>\n<li>allow-same-origin&#xff1a;\u5141\u8bb8\u5d4c\u5165\u7684\u9875\u9762\u548c\u5f53\u524d\u9875\u9762\u201c\u89c6\u4e3a\u540c\u6e90\u201d\u3002\u4ec0\u4e48\u662f\u201c\u540c\u6e90\u201d&#xff1f;\u7b80\u5355\u8bf4\u5c31\u662f\u201c\u57df\u540d\u3001\u534f\u8bae\u3001\u7aef\u53e3\u90fd\u4e00\u6837\u201d\u3002\u540c\u6e90\u7684\u9875\u9762\u53ef\u4ee5\u4e92\u76f8\u8bbf\u95ee\u6570\u636e&#xff0c;\u4e0d\u540c\u6e90\u7684\u5219\u88ab\u9650\u5236\u3002\u5982\u679c\u8bbe\u7f6e\u4e86\u8fd9\u4e2a\u53c2\u6570&#xff0c;\u5d4c\u5165\u9875\u9762\u5c31\u53ef\u4ee5\u548c\u5f53\u524d\u9875\u9762\u5171\u4eab\u6570\u636e\u4e86&#xff1b;<\/li>\n<li>allow-forms&#xff1a;\u5141\u8bb8\u5d4c\u5165\u7684\u9875\u9762\u63d0\u4ea4\u8868\u5355\u3002\u6bd4\u5982\u5d4c\u5165\u7684\u9875\u9762\u6709\u4e2a\u6ce8\u518c\u8868\u5355&#xff0c;\u8fd9\u4e2a\u53c2\u6570\u63a7\u5236\u662f\u5426\u5141\u8bb8\u7528\u6237\u63d0\u4ea4&#xff1b;<\/li>\n<li>allow-popups&#xff1a;\u5141\u8bb8\u5d4c\u5165\u7684\u9875\u9762\u5f39\u51fa\u65b0\u7a97\u53e3&#xff08;\u6bd4\u5982window.open\u6253\u5f00\u7684\u7a97\u53e3&#xff09;&#xff1b;<\/li>\n<li>allow-popups-to-escape-sandbox&#xff1a;\u5141\u8bb8\u5d4c\u5165\u9875\u9762\u5f39\u51fa\u7684\u65b0\u7a97\u53e3\u201c\u8131\u79bb\u9694\u79bb\u7f69\u201d\u3002\u4e5f\u5c31\u662f\u8bf4&#xff0c;\u5f39\u51fa\u7684\u7a97\u53e3\u4e0d\u53d7\u5f53\u524dsandbox\u7684\u9650\u5236&#xff0c;\u53ef\u80fd\u62e5\u6709\u66f4\u591a\u6743\u9650\u3002<\/li>\n<\/ul>\n<h3>\u6700\u5371\u9669\u7684\u7ec4\u5408&#xff1a;allow-scripts &#043; allow-same-origin<\/h3>\n<p>\u8fd9\u91cc\u8981\u5212\u91cd\u70b9&#xff1a;\u5f3a\u70c8\u5efa\u8bae\u4e0d\u8981\u540c\u65f6\u4f7f\u7528allow-scripts\u548callow-same-origin\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48&#xff1f;\u5982\u679c\u540c\u65f6\u5141\u8bb8\u5d4c\u5165\u9875\u9762\u8fd0\u884c\u811a\u672c&#xff08;allow-scripts&#xff09;&#xff0c;\u53c8\u8ba9\u5b83\u548c\u5f53\u524d\u9875\u9762\u540c\u6e90&#xff08;allow-same-origin&#xff09;&#xff0c;\u5c31\u76f8\u5f53\u4e8e\u7ed9\u4e86\u5d4c\u5165\u9875\u9762\u201c\u65e2\u80fd\u6267\u884c\u4ee3\u7801&#xff0c;\u53c8\u80fd\u8bbf\u95ee\u5f53\u524d\u9875\u9762\u6570\u636e\u201d\u7684\u6743\u9650\u3002\u5982\u679c\u5d4c\u5165\u7684\u9875\u9762\u662f\u4e0d\u53ef\u4fe1\u7684&#xff0c;\u653b\u51fb\u8005\u5c31\u53ef\u4ee5\u901a\u8fc7\u811a\u672c\u7a83\u53d6\u5f53\u524d\u9875\u9762\u7684Cookie\u3001LocalStorage&#xff0c;\u751a\u81f3\u4fee\u6539\u9875\u9762\u5185\u5bb9&#xff0c;\u98ce\u9669\u6781\u5927\u3002<\/p>\n<h3>\u4e3e\u4e2a\u4f8b\u5b50&#xff1a;\u6b63\u786e\u4f7f\u7528sandbox<\/h3>\n<p>\u5047\u8bbe\u6211\u4eec\u8981\u5d4c\u5165\u4e00\u4e2a\u7b2c\u4e09\u65b9\u7684\u5e7f\u544a\u9875\u9762&#xff0c;\u6211\u4eec\u53ea\u5e0c\u671b\u5b83\u80fd\u663e\u793a\u5185\u5bb9\u548c\u63d0\u4ea4\u8868\u5355&#xff0c;\u4e0d\u5e0c\u671b\u5b83\u8fd0\u884c\u811a\u672c\u6216\u8df3\u8f6c\u9875\u9762&#xff0c;\u90a3\u4e48\u53ef\u4ee5\u8fd9\u6837\u8bbe\u7f6e&#xff1a;<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>iframe<\/span> <span class=\"token attr-name\">src<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>https:\/\/\u7b2c\u4e09\u65b9\u5e7f\u544a.com<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token attr-name\">sandbox<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>allow-forms<span class=\"token punctuation\">&#034;<\/span><\/span><span class=\"token punctuation\">&gt;<\/span><\/span><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>iframe<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u8fd9\u91cc\u53ea\u7ed9\u4e86allow-forms\u6743\u9650&#xff0c;\u5176\u4ed6\u529f\u80fd&#xff08;\u5982\u811a\u672c\u3001\u8df3\u8f6c&#xff09;\u90fd\u88ab\u7981\u7528&#xff0c;\u5927\u5927\u964d\u4f4e\u4e86\u98ce\u9669\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>iframe\u7684sandbox\u5c5e\u6027\u662f\u9632\u5fa1\u5d4c\u5165\u9875\u9762\u98ce\u9669\u7684\u91cd\u8981\u5de5\u5177&#xff0c;\u5b83\u901a\u8fc7\u9650\u5236\u5d4c\u5165\u9875\u9762\u7684\u6743\u9650&#xff0c;\u9632\u6b62\u6076\u610f\u884c\u4e3a\u3002\u4f7f\u7528\u65f6\u8981\u6ce8\u610f&#xff1a;<\/p>\n<li>\u6839\u636e\u9700\u6c42\u6700\u5c0f\u5316\u6743\u9650&#xff1a;\u53ea\u5f00\u542f\u5fc5\u9700\u7684\u53c2\u6570&#xff08;\u6bd4\u5982\u53ea\u9700\u8981\u663e\u793a\u5185\u5bb9\u5c31\u4e0d\u52a0\u4efb\u4f55\u53c2\u6570&#xff0c;\u9ed8\u8ba4\u5168\u9650\u5236&#xff09;&#xff1b;<\/li>\n<li>\u7edd\u5bf9\u907f\u514d\u540c\u65f6\u4f7f\u7528allow-scripts\u548callow-same-origin&#xff0c;\u8fd9\u4f1a\u8ba9\u9694\u79bb\u5931\u53bb\u610f\u4e49&#xff1b;<\/li>\n<li>\u5373\u4f7f\u52a0\u4e86sandbox&#xff0c;\u4e5f\u8981\u5c3d\u91cf\u53ea\u5d4c\u5165\u53ef\u4fe1\u6765\u6e90\u7684\u9875\u9762&#xff0c;\u4e0d\u53ef\u4fe1\u7684\u5185\u5bb9\u59cb\u7ec8\u6709\u98ce\u9669\u3002<\/li>\n<h2>3 noreferrer \u5c5e\u6027<\/h2>\n<h3>\u4ec0\u4e48\u662fReferer&#xff1f;<\/h3>\n<p>\u5728\u8bb2noreferrer\u4e4b\u524d&#xff0c;\u5148\u4e86\u89e3\u4e00\u4e2a\u6982\u5ff5&#xff1a;Referer&#xff08;\u8bf7\u6c42\u6765\u6e90&#xff09;\u3002\u5f53\u4f60\u70b9\u51fb\u7f51\u9875\u4e2d\u7684\u94fe\u63a5&#xff08;\u6bd4\u5982&lt;a&gt;\u6807\u7b7e&#xff09;\u8df3\u8f6c\u5230\u53e6\u4e00\u4e2a\u9875\u9762\u65f6&#xff0c;\u6d4f\u89c8\u5668\u4f1a\u5728\u8bf7\u6c42\u5934\u91cc\u52a0\u4e0aReferer\u5b57\u6bb5&#xff0c;\u544a\u8bc9\u65b0\u9875\u9762\u201c\u6211\u662f\u4ece\u54ea\u4e2a\u9875\u9762\u8df3\u8fc7\u6765\u7684\u201d\u3002<\/p>\n<p>\u6bd4\u5982&#xff0c;\u4f60\u4ecehttps:\/\/a.com\u70b9\u51fb\u94fe\u63a5\u5230https:\/\/b.com&#xff0c;b.com\u7684\u670d\u52a1\u5668\u4f1a\u6536\u5230\u4e00\u4e2aReferer: https:\/\/a.com\u7684\u8bf7\u6c42\u5934&#xff0c;\u8fd9\u6837b.com\u5c31\u77e5\u9053\u7528\u6237\u6765\u81eaa.com\u3002<\/p>\n<h3>noreferrer&#xff1a;\u9690\u85cf\u4f60\u7684\u201c\u6765\u6e90\u201d<\/h3>\n<p>noreferrer\u662f&lt;a&gt;\u548c&lt;area&gt;\u6807\u7b7e\u7684\u4e00\u4e2a\u5c5e\u6027&#xff0c;\u5b83\u7684\u4f5c\u7528\u5f88\u7b80\u5355&#xff1a;\u5f53\u7528\u6237\u70b9\u51fb\u5e26\u6709\u8fd9\u4e2a\u5c5e\u6027\u7684\u94fe\u63a5\u65f6&#xff0c;\u6d4f\u89c8\u5668\u4e0d\u4f1a\u5728\u8bf7\u6c42\u5934\u91cc\u53d1\u9001Referer\u4fe1\u606f\u3002<\/p>\n<p>\u4e3a\u4ec0\u4e48\u9700\u8981\u9690\u85cf\u6765\u6e90&#xff1f;\u56e0\u4e3aReferer\u53ef\u80fd\u5305\u542b\u654f\u611f\u4fe1\u606f\u3002\u6bd4\u5982&#xff0c;\u4f60\u5728a.com\u7684\u4e00\u4e2a\u5305\u542b\u7528\u6237ID\u7684\u9875\u9762&#xff08;https:\/\/a.com\/user?ID&#061;12345&#xff09;\u70b9\u51fb\u4e86\u4e00\u4e2a\u5230b.com\u7684\u94fe\u63a5&#xff0c;\u5982\u679c\u4e0d\u9690\u85cfReferer&#xff0c;b.com\u5c31\u4f1a\u77e5\u9053\u7528\u6237\u7684ID\u662f12345&#xff0c;\u8fd9\u53ef\u80fd\u6cc4\u9732\u7528\u6237\u9690\u79c1\u3002<\/p>\n<p>\u4f7f\u7528\u65b9\u6cd5\u4e5f\u5f88\u7b80\u5355&#xff0c;\u5728&lt;a&gt;\u6807\u7b7e\u91cc\u52a0noreferrer\u5373\u53ef&#xff1a;<\/p>\n<p><span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;<\/span>a<\/span> <span class=\"token attr-name\">href<\/span><span class=\"token attr-value\"><span class=\"token punctuation attr-equals\">&#061;<\/span><span class=\"token punctuation\">&#034;<\/span>https:\/\/b.com<span class=\"token punctuation\">&#034;<\/span><\/span> <span class=\"token attr-name\">noreferrer<\/span><span class=\"token punctuation\">&gt;<\/span><\/span>\u70b9\u51fb\u8df3\u8f6c\u5230b.com<span class=\"token tag\"><span class=\"token tag\"><span class=\"token punctuation\">&lt;\/<\/span>a<\/span><span class=\"token punctuation\">&gt;<\/span><\/span><\/p>\n<p>\u8fd9\u6837&#xff0c;\u8df3\u8f6c\u65f6b.com\u5c31\u4e0d\u4f1a\u6536\u5230Referer\u4fe1\u606f\u4e86\u3002<\/p>\n<h3>\u6ce8\u610f&#xff1a;noreferrer\u548cnoopener\u7684\u533a\u522b<\/h3>\n<p>\u53ef\u80fd\u6709\u5c0f\u767d\u4f1a\u6df7\u6dc6noreferrer\u548cnoopener&#xff08;\u53e6\u4e00\u4e2a\u5c5e\u6027&#xff09;\u3002\u7b80\u5355\u8bf4&#xff1a;<\/p>\n<ul>\n<li>noreferrer&#xff1a;\u9690\u85cfReferer&#xff0c;\u540c\u65f6\u4e5f\u4f1a\u8ba9\u65b0\u9875\u9762\u65e0\u6cd5\u901a\u8fc7window.opener\u8bbf\u95ee\u539f\u9875\u9762&#xff08;\u540e\u9762\u201c\u9493\u9c7c\u98ce\u9669\u201d\u90e8\u5206\u4f1a\u8bb2window.opener&#xff09;&#xff1b;<\/li>\n<li>noopener&#xff1a;\u53ea\u963b\u6b62\u65b0\u9875\u9762\u901a\u8fc7window.opener\u8bbf\u95ee\u539f\u9875\u9762&#xff0c;\u4e0d\u5f71\u54cdReferer\u7684\u53d1\u9001\u3002<\/li>\n<\/ul>\n<p>\u5982\u679c\u65e2\u60f3\u9690\u85cf\u6765\u6e90&#xff0c;\u53c8\u60f3\u9632\u6b62window.opener\u88ab\u6ee5\u7528&#xff0c;\u7528noreferrer\u66f4\u5408\u9002\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>noreferrer\u5c5e\u6027\u7684\u6838\u5fc3\u4f5c\u7528\u662f\u4fdd\u62a4\u7528\u6237\u7684\u6765\u6e90\u9690\u79c1&#xff0c;\u9632\u6b62\u654f\u611f\u7684Referer\u4fe1\u606f\u88ab\u7b2c\u4e09\u65b9\u7f51\u7ad9\u83b7\u53d6\u3002\u5728\u4ee5\u4e0b\u573a\u666f\u5efa\u8bae\u4f7f\u7528&#xff1a;<\/p>\n<li>\u94fe\u63a5\u6307\u5411\u4e0d\u53ef\u4fe1\u7684\u7b2c\u4e09\u65b9\u7f51\u7ad9\u65f6&#xff1b;<\/li>\n<li>\u539f\u9875\u9762URL\u5305\u542b\u7528\u6237ID\u3001\u4f1a\u8bddID\u7b49\u654f\u611f\u4fe1\u606f\u65f6&#xff1b;<\/li>\n<li>\u5e0c\u671b\u4e25\u683c\u4fdd\u62a4\u7528\u6237\u8bbf\u95ee\u8def\u5f84\u9690\u79c1\u65f6\u3002 \u4f7f\u7528\u65f6\u53ea\u9700\u5728&lt;a&gt;\u6216&lt;area&gt;\u6807\u7b7e\u4e2d\u6dfb\u52a0noreferrer\u5c5e\u6027&#xff0c;\u7b80\u5355\u6709\u6548\u3002<\/li>\n<h2>4 postMessage&#xff1a;\u8de8\u7a97\u53e3\u901a\u4fe1\u7684\u201c\u5b89\u5168\u7ef3\u201d<\/h2>\n<h3>\u4ec0\u4e48\u662fpostMessage&#xff1f;<\/h3>\n<p>\u5728HTML5\u4e4b\u524d&#xff0c;\u7531\u4e8e\u201c\u540c\u6e90\u7b56\u7565\u201d&#xff08;\u4e0d\u540c\u57df\u540d\u3001\u534f\u8bae\u6216\u7aef\u53e3\u7684\u9875\u9762\u4e0d\u80fd\u4e92\u76f8\u8bbf\u95ee\u6570\u636e&#xff09;&#xff0c;\u4e24\u4e2a\u4e0d\u540c\u7a97\u53e3&#xff08;\u6bd4\u5982\u4e24\u4e2a\u6807\u7b7e\u9875\u3001\u7236\u9875\u9762\u548ciframe&#xff09;\u4e4b\u95f4\u5f88\u96be\u901a\u4fe1\u3002\u800cpostMessage\u5c31\u662fHTML5\u63a8\u51fa\u7684\u8de8\u7a97\u53e3\u901a\u4fe1\u5de5\u5177&#xff0c;\u5b83\u5141\u8bb8\u4efb\u4f55\u7a97\u53e3\u5411\u5176\u4ed6\u7a97\u53e3\u53d1\u9001\u6587\u672c\u6d88\u606f&#xff0c;\u4e0d\u7ba1\u662f\u5426\u540c\u6e90\u3002<\/p>\n<p>\u6bd4\u5982&#xff0c;a.com\u7684\u9875\u9762\u53ef\u4ee5\u7528postMessage\u7ed9b.com\u7684\u9875\u9762\u53d1\u9001\u6d88\u606f&#xff0c;\u5b9e\u73b0\u6570\u636e\u4f20\u9012\u3002\u8fd9\u5728\u9700\u8981\u8de8\u57df\u534f\u4f5c\u7684\u573a\u666f&#xff08;\u5982iframe\u5d4c\u5165\u7b2c\u4e09\u65b9\u767b\u5f55\u9875&#xff09;\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h3>postMessage\u7684\u5b89\u5168\u98ce\u9669<\/h3>\n<p>\u867d\u7136postMessage\u89e3\u51b3\u4e86\u8de8\u57df\u901a\u4fe1\u7684\u95ee\u9898&#xff0c;\u4f46\u5982\u679c\u7528\u4e0d\u597d&#xff0c;\u5c31\u4f1a\u53d8\u6210\u5b89\u5168\u6f0f\u6d1e\u7684\u5165\u53e3\u3002\u4e3b\u8981\u6709\u4e24\u4e2a\u98ce\u9669\u70b9&#xff1a;<\/p>\n<h4>\u98ce\u96691&#xff1a;\u4e0d\u9a8c\u8bc1\u63a5\u6536\u7a97\u53e3\u7684\u6765\u6e90<\/h4>\n<p>postMessage\u53d1\u9001\u6d88\u606f\u65f6&#xff0c;\u9700\u8981\u6307\u5b9a\u63a5\u6536\u6d88\u606f\u7684\u7a97\u53e3\u548c\u201c\u76ee\u6807\u6e90\u201d&#xff08;\u5373\u63a5\u6536\u65b9\u7684\u57df\u540d&#xff09;\u3002\u5982\u679c\u76ee\u6807\u6e90\u8bbe\u4e3a&#034;*&#034;&#xff08;\u8868\u793a\u4efb\u4f55\u57df\u540d\u90fd\u53ef\u4ee5\u63a5\u6536&#xff09;&#xff0c;\u90a3\u4e48\u6076\u610f\u7f51\u7ad9\u53ef\u80fd\u4f1a\u4f2a\u9020\u4e00\u4e2a\u7a97\u53e3\u63a5\u6536\u4f60\u7684\u6d88\u606f&#xff0c;\u7a83\u53d6\u654f\u611f\u6570\u636e\u3002<\/p>\n<p>\u6bd4\u5982&#xff0c;\u9519\u8bef\u7684\u7528\u6cd5&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u5411\u4efb\u4f55\u7a97\u53e3\u53d1\u9001\u6d88\u606f&#xff0c;\u5371\u9669&#xff01;<\/span><br \/>\notherWindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">postMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5305\u542b\u7528\u6237\u4fe1\u606f\u7684\u6d88\u606f&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;*&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc\u7684&#034;*&#034;\u4f1a\u8ba9\u6d88\u606f\u88ab\u6240\u6709\u7a97\u53e3\u63a5\u6536&#xff0c;\u4e00\u65e6\u6d88\u606f\u5305\u542b\u7528\u6237\u5bc6\u7801\u3001Token\u7b49\u654f\u611f\u4fe1\u606f&#xff0c;\u5c31\u4f1a\u88ab\u653b\u51fb\u8005\u7a83\u53d6\u3002<\/p>\n<h4>\u98ce\u96692&#xff1a;\u6d88\u606f\u5185\u5bb9\u672a\u8fc7\u6ee4&#xff0c;\u5bfc\u81f4XSS<\/h4>\n<p>\u5f53\u63a5\u6536\u65b9\u6536\u5230\u6d88\u606f\u540e&#xff0c;\u5982\u679c\u76f4\u63a5\u628a\u6d88\u606f\u5185\u5bb9\u63d2\u5165\u5230\u9875\u9762\u4e2d&#xff08;\u6bd4\u5982\u7528innerHTML\u663e\u793a&#xff09;&#xff0c;\u800c\u6d88\u606f\u91cc\u5305\u542b\u6076\u610f\u811a\u672c&#xff0c;\u5c31\u4f1a\u89e6\u53d1XSS\u653b\u51fb\u3002<\/p>\n<p>\u6bd4\u5982&#xff0c;\u63a5\u6536\u65b9\u7684\u4ee3\u7801&#xff1a;<\/p>\n<p>window<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">function<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u76f4\u63a5\u5c06\u6d88\u606f\u63d2\u5165\u9875\u9762&#xff0c;\u5371\u9669&#xff01;<\/span><br \/>\n  document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>innerHTML <span class=\"token operator\">&#061;<\/span> event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u653b\u51fb\u8005\u53d1\u9001\u7684\u6d88\u606f\u662f&lt;script&gt;alert(&#039;\u7a83\u53d6Cookie&#039;)&lt;\/script&gt;&#xff0c;\u8fd9\u6bb5\u811a\u672c\u5c31\u4f1a\u88ab\u6267\u884c\u3002<\/p>\n<h3>\u5982\u4f55\u5b89\u5168\u4f7f\u7528postMessage&#xff1f;<\/h3>\n<p>\u9488\u5bf9\u4ee5\u4e0a\u98ce\u9669&#xff0c;\u6b63\u786e\u7684\u505a\u6cd5\u662f&#xff1a;<\/p>\n<li>\n<p>\u53d1\u9001\u6d88\u606f\u65f6&#xff0c;\u660e\u786e\u6307\u5b9a\u76ee\u6807\u6e90&#xff08;\u63a5\u6536\u65b9\u7684\u57df\u540d&#xff09;&#xff0c;\u4e0d\u8981\u7528&#034;*&#034;\u3002 \u6b63\u786e\u793a\u4f8b&#xff1a;<\/p>\n<p> <span class=\"token comment\">\/\/ \u53ea\u5411https:\/\/trusted.com\u53d1\u9001\u6d88\u606f<\/span><br \/>\notherWindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">postMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5b89\u5168\u7684\u6d88\u606f&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;https:\/\/trusted.com&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\n<p>\u63a5\u6536\u6d88\u606f\u65f6&#xff0c;\u5148\u9a8c\u8bc1\u53d1\u9001\u65b9\u7684\u6765\u6e90&#xff08;event.origin&#xff09;&#xff0c;\u786e\u4fdd\u662f\u53ef\u4fe1\u7684\u57df\u540d\u3002 \u6b63\u786e\u793a\u4f8b&#xff1a;<\/p>\n<p> <span class=\"token keyword\">function<\/span> <span class=\"token function\">receiveMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u53ea\u5904\u7406\u6765\u81eahttps:\/\/trusted.com\u7684\u6d88\u606f<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>origin <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token string\">&#034;https:\/\/trusted.com&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u4e0d\u662f\u53ef\u4fe1\u6765\u6e90&#xff0c;\u76f4\u63a5\u5ffd\u7565<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u5904\u7406\u6d88\u606f&#xff08;\u5982\u679c\u8981\u63d2\u5165\u9875\u9762&#xff0c;\u9700\u5148\u8fc7\u6ee4\u811a\u672c&#xff09;<\/span><br \/>\n  document<span class=\"token punctuation\">.<\/span>body<span class=\"token punctuation\">.<\/span>textContent <span class=\"token operator\">&#061;<\/span> event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u7528textContent\u800c\u975einnerHTML&#xff0c;\u907f\u514dXSS<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">,<\/span> receiveMessage<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span>\n <\/li>\n<li>\n<p>\u5bf9\u6d88\u606f\u5185\u5bb9\u8fdb\u884c\u8fc7\u6ee4&#xff1a;\u5982\u679c\u9700\u8981\u5c06\u6d88\u606f\u663e\u793a\u5728\u9875\u9762\u4e2d&#xff0c;\u5c3d\u91cf\u7528textContent&#xff08;\u53ea\u663e\u793a\u6587\u672c&#xff0c;\u4e0d\u89e3\u6790HTML&#xff09;&#xff0c;\u6216\u8005\u5bf9\u6d88\u606f\u4e2d\u7684&lt;script&gt;\u7b49\u5371\u9669\u6807\u7b7e\u8fdb\u884c\u8fc7\u6ee4\u3002<\/p>\n<\/li>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>postMessage\u662f\u8de8\u7a97\u53e3\u901a\u4fe1\u7684\u5f3a\u5927\u5de5\u5177&#xff0c;\u4f46\u5fc5\u987b\u505a\u597d\u5b89\u5168\u9632\u62a4&#xff1a;<\/p>\n<li>\u53d1\u9001\u6d88\u606f\u65f6&#xff0c;\u4e25\u683c\u6307\u5b9a\u76ee\u6807\u6e90&#xff08;\u5982&#034;https:\/\/trusted.com&#034;&#xff09;&#xff0c;\u62d2\u7edd\u4f7f\u7528&#034;*&#034;&#xff1b;<\/li>\n<li>\u63a5\u6536\u6d88\u606f\u65f6&#xff0c;\u5148\u6821\u9a8c\u53d1\u9001\u65b9\u7684event.origin&#xff0c;\u53ea\u5904\u7406\u53ef\u4fe1\u6765\u6e90\u7684\u6d88\u606f&#xff1b;<\/li>\n<li>\u5904\u7406\u6d88\u606f\u5185\u5bb9\u65f6&#xff0c;\u907f\u514d\u76f4\u63a5\u7528innerHTML\u63d2\u5165\u9875\u9762&#xff0c;\u9632\u6b62XSS\u653b\u51fb\u3002 \u8bb0\u4f4f&#xff1a;\u8de8\u57df\u901a\u4fe1\u5c31\u50cf\u201c\u8d70\u94a2\u4e1d\u201d&#xff0c;postMessage\u662f\u90a3\u6839\u201c\u7ef3\u201d&#xff0c;\u800c\u9a8c\u8bc1\u548c\u8fc7\u6ee4\u5c31\u662f\u201c\u5b89\u5168\u7f51\u201d\u3002<\/li>\n<h2>5 WebStorage&#xff1a;\u672c\u5730\u5b58\u50a8\u7684\u201c\u5b89\u5168\u5751\u201d<\/h2>\n<h3>\u4ec0\u4e48\u662fWebStorage&#xff1f;<\/h3>\n<p>WebStorage\u662fHTML5\u63d0\u4f9b\u7684\u672c\u5730\u5b58\u50a8\u6280\u672f&#xff0c;\u7b80\u5355\u8bf4\u5c31\u662f\u8ba9\u7f51\u9875\u80fd\u5728\u7528\u6237\u7684\u6d4f\u89c8\u5668\u91cc\u4fdd\u5b58\u6570\u636e&#xff08;\u6bd4\u5982\u7528\u6237\u504f\u597d\u8bbe\u7f6e\u3001\u767b\u5f55\u72b6\u6001\u7b49&#xff09;&#xff0c;\u4e0d\u7528\u6bcf\u6b21\u90fd\u4ece\u670d\u52a1\u5668\u83b7\u53d6\u3002\u5b83\u5206\u4e3a\u4e24\u79cd&#xff1a;<\/p>\n<ul>\n<li>Session Storage&#xff08;\u4f1a\u8bdd\u5b58\u50a8&#xff09;&#xff1a;\u6570\u636e\u53ea\u5728\u5f53\u524d\u6d4f\u89c8\u5668\u4f1a\u8bdd\u4e2d\u6709\u6548&#xff0c;\u5173\u95ed\u6d4f\u89c8\u5668&#xff08;\u6216\u6807\u7b7e\u9875&#xff09;\u540e\u6570\u636e\u5c31\u4f1a\u88ab\u5220\u9664&#xff1b;<\/li>\n<li>Local Storage&#xff08;\u672c\u5730\u5b58\u50a8&#xff09;&#xff1a;\u6570\u636e\u4f1a\u4e00\u76f4\u4fdd\u5b58\u5728\u6d4f\u89c8\u5668\u91cc&#xff0c;\u5373\u4f7f\u5173\u95ed\u6d4f\u89c8\u5668\u518d\u6253\u5f00&#xff0c;\u6570\u636e\u4ecd\u7136\u5b58\u5728&#xff08;\u9664\u975e\u624b\u52a8\u5220\u9664&#xff09;\u3002<\/li>\n<\/ul>\n<h3>WebStorage\u7684\u4f7f\u7528\u65b9\u6cd5<\/h3>\n<p>\u4f7f\u7528\u8d77\u6765\u5f88\u7b80\u5355&#xff0c;\u901a\u8fc7JavaScript\u5c31\u80fd\u64cd\u4f5c&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u5b58\u50a8\u6570\u636e\u5230Session Storage<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span>sessionStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">setItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;username&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u5f20\u4e09&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u4eceSession Storage\u8bfb\u53d6\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">let<\/span> name <span class=\"token operator\">&#061;<\/span> window<span class=\"token punctuation\">.<\/span>sessionStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">getItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;username&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u5b58\u50a8\u6570\u636e\u5230Local Storage<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span>localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">setItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;theme&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;dark&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n<span class=\"token comment\">\/\/ \u4eceLocal Storage\u8bfb\u53d6\u6570\u636e<\/span><br \/>\n<span class=\"token keyword\">let<\/span> theme <span class=\"token operator\">&#061;<\/span> window<span class=\"token punctuation\">.<\/span>localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">getItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;theme&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u53e6\u5916&#xff0c;Firefox\u6d4f\u89c8\u5668\u66fe\u7ecf\u5355\u72ec\u5b9e\u73b0\u8fc7globalStorage&#xff0c;\u53ef\u4ee5\u6309\u57df\u540d\u5b58\u50a8\u6570\u636e&#xff0c;\u7528\u6cd5\u5982\u4e0b&#xff08;\u4f46\u73b0\u5728\u5df2\u4e0d\u63a8\u8350\u4f7f\u7528&#xff0c;\u4e86\u89e3\u5373\u53ef&#xff09;&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u7ed9\u6307\u5b9a\u57df\u540d\u5b58\u50a8\u6570\u636e&#xff08;\u4ec5Firefox&#xff09;<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span>globalStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">namedItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;https:\/\/example.com&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span><span class=\"token function\">setItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;key&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;value&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<h3>WebStorage\u7684\u5b89\u5168\u98ce\u9669<\/h3>\n<p>WebStorage\u867d\u7136\u65b9\u4fbf&#xff0c;\u4f46\u6709\u4e2a\u5927\u95ee\u9898&#xff1a;\u5b83\u53d7\u201c\u540c\u6e90\u7b56\u7565\u201d\u9650\u5236&#xff0c;\u4f46\u6570\u636e\u662f\u660e\u6587\u5b58\u50a8\u5728\u672c\u5730\u7684\u3002<\/p>\n<ul>\n<li>\u540c\u6e90\u7b56\u7565\u4fdd\u62a4&#xff1a;\u53ea\u6709\u540c\u4e00\u4e2a\u57df\u540d\u7684\u9875\u9762\u624d\u80fd\u8bbf\u95ee\u5bf9\u5e94\u7684WebStorage\u6570\u636e&#xff08;\u6bd4\u5982a.com\u7684\u9875\u9762\u4e0d\u80fd\u8bbf\u95eeb.com\u7684Local Storage&#xff09;&#xff0c;\u8fd9\u80fd\u9632\u6b62\u8de8\u57df\u7a83\u53d6&#xff1b;<\/li>\n<li>\u660e\u6587\u5b58\u50a8\u98ce\u9669&#xff1a;\u6570\u636e\u4ee5\u660e\u6587\u5f62\u5f0f\u5b58\u5728\u6d4f\u89c8\u5668\u7684\u672c\u5730\u6587\u4ef6\u4e2d&#xff0c;\u5982\u679c\u7528\u6237\u7684\u8bbe\u5907\u88ab\u7269\u7406\u8bbf\u95ee&#xff08;\u6bd4\u5982\u522b\u4eba\u62ff\u5230\u4f60\u7684\u7535\u8111&#xff09;&#xff0c;\u6216\u8005\u6d4f\u89c8\u5668\u88ab\u6076\u610f\u8f6f\u4ef6\u5165\u4fb5&#xff0c;\u8fd9\u4e9b\u6570\u636e\u53ef\u80fd\u88ab\u76f4\u63a5\u8bfb\u53d6\u3002<\/li>\n<\/ul>\n<p>\u66f4\u91cd\u8981\u7684\u662f&#xff1a;\u7edd\u5bf9\u4e0d\u8981\u7528WebStorage\u5b58\u50a8\u654f\u611f\u4fe1\u606f&#xff0c;\u6bd4\u5982\u7528\u6237\u5bc6\u7801\u3001\u94f6\u884c\u5361\u53f7\u3001\u767b\u5f55Token&#xff08;\u53ef\u80fd\u7528\u4e8e\u81ea\u52a8\u767b\u5f55&#xff09;\u7b49\u3002\u4e00\u65e6\u8fd9\u4e9b\u4fe1\u606f\u88ab\u7a83\u53d6&#xff0c;\u653b\u51fb\u8005\u53ef\u80fd\u76f4\u63a5\u767b\u5f55\u7528\u6237\u8d26\u53f7&#xff0c;\u9020\u6210\u635f\u5931\u3002<\/p>\n<h3>\u4e3e\u4e2a\u5371\u9669\u7684\u4f8b\u5b50<\/h3>\n<p>\u5047\u8bbe\u67d0\u4e2a\u7f51\u7ad9\u4e3a\u4e86\u201c\u65b9\u4fbf\u7528\u6237\u201d&#xff0c;\u628a\u767b\u5f55\u5bc6\u7801\u5b58\u5728\u4e86Local Storage\u91cc&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u5371\u9669&#xff01;\u7edd\u5bf9\u4e0d\u8981\u8fd9\u4e48\u505a&#xff01;<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span>localStorage<span class=\"token punctuation\">.<\/span><span class=\"token function\">setItem<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;password&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;user123456&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u5982\u679c\u653b\u51fb\u8005\u901a\u8fc7XSS\u653b\u51fb\u83b7\u53d6\u4e86\u8fd9\u4e2a\u6570\u636e&#xff0c;\u5c31\u80fd\u76f4\u63a5\u62ff\u5230\u7528\u6237\u7684\u5bc6\u7801\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>WebStorage\u662f\u672c\u5730\u5b58\u50a8\u7684\u5b9e\u7528\u5de5\u5177&#xff0c;\u4f46\u4f7f\u7528\u65f6\u5fc5\u987b\u7262\u8bb0&#xff1a;<\/p>\n<li>\u533a\u5206Session Storage\u548cLocal Storage&#xff1a;\u524d\u8005\u4e34\u65f6\u5b58\u50a8&#xff0c;\u540e\u8005\u957f\u671f\u5b58\u50a8&#xff0c;\u6839\u636e\u9700\u6c42\u9009\u62e9&#xff1b;<\/li>\n<li>\u7981\u6b62\u5b58\u50a8\u654f\u611f\u4fe1\u606f&#xff1a;\u5bc6\u7801\u3001Token\u3001\u8eab\u4efd\u8bc1\u53f7\u7b49\u7edd\u5bf9\u4e0d\u80fd\u5b58\u5728WebStorage\u4e2d&#xff1b;<\/li>\n<li>\u5373\u4f7f\u5b58\u50a8\u975e\u654f\u611f\u6570\u636e&#xff0c;\u4e5f\u8981\u6ce8\u610f&#xff1a;\u5982\u679c\u9875\u9762\u5b58\u5728XSS\u6f0f\u6d1e&#xff0c;WebStorage\u7684\u6570\u636e\u53ef\u80fd\u88ab\u7a83\u53d6&#xff08;\u56e0\u4e3a\u540c\u6e90\u9875\u9762\u80fd\u8bbf\u95ee&#xff09;&#xff0c;\u6240\u4ee5\u4ecd\u9700\u505a\u597dXSS\u9632\u5fa1\u3002<\/li>\n<h2>6 \u4f7f\u7528postMessage\u5b9e\u73b0\u8de8\u57df&#xff1a;\u76ee\u6807\u6e90\u4e0d\u80fd\u201c\u5077\u61d2\u201d<\/h2>\n<h3>\u8de8\u57df\u901a\u4fe1\u7684\u5e38\u89c1\u9700\u6c42<\/h3>\n<p>\u5728\u5b9e\u9645\u5f00\u53d1\u4e2d&#xff0c;\u8de8\u57df\u901a\u4fe1\u5f88\u5e38\u89c1\u3002\u6bd4\u5982&#xff0c;a.com\u7684\u9875\u9762\u5d4c\u5165\u4e86b.com\u7684iframe&#xff0c;\u4e24\u8005\u9700\u8981\u4ea4\u6362\u6570\u636e&#xff08;\u5982\u7528\u6237\u767b\u5f55\u72b6\u6001&#xff09;&#xff0c;\u8fd9\u65f6\u5019\u5c31\u4f1a\u7528\u5230postMessage\u3002<\/p>\n<h3>\u9519\u8bef\u7528\u6cd5&#xff1a;\u56fe\u7701\u4e8b\u7528\u201c*\u201d<\/h3>\n<p>\u5f88\u591a\u65b0\u624b\u4e3a\u4e86\u56fe\u65b9\u4fbf&#xff0c;\u4f1a\u628apostMessage\u7684\u76ee\u6807\u6e90\u8bbe\u4e3a&#034;*&#034;&#xff0c;\u8868\u793a\u201c\u4efb\u4f55\u57df\u540d\u90fd\u53ef\u4ee5\u63a5\u6536\u8fd9\u4e2a\u6d88\u606f\u201d\u3002\u6bd4\u5982&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u9519\u8bef\u793a\u4f8b&#xff1a;\u5411\u6240\u6709\u57df\u540d\u53d1\u9001\u6d88\u606f<\/span><br \/>\n<span class=\"token keyword\">let<\/span> iframeWindow <span class=\"token operator\">&#061;<\/span> document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;myIframe&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>contentWindow<span class=\"token punctuation\">;<\/span><br \/>\niframeWindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">postMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u7528\u6237\u4fe1\u606f&#xff1a;xxx&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;*&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u79cd\u505a\u6cd5\u7684\u98ce\u9669\u5728\u4e8e&#xff1a;\u5982\u679c\u6709\u6076\u610f\u7f51\u7ad9\u901a\u8fc7\u67d0\u79cd\u65b9\u5f0f&#xff08;\u6bd4\u5982\u4f2a\u9020iframe&#xff09;\u6210\u4e3a\u6d88\u606f\u7684\u63a5\u6536\u65b9&#xff0c;\u5c31\u80fd\u8f7b\u677e\u7a83\u53d6\u6d88\u606f\u4e2d\u7684\u6570\u636e\u3002\u5c24\u5176\u662f\u6d88\u606f\u5305\u542b\u7528\u6237ID\u3001\u6743\u9650\u4fe1\u606f\u7b49\u654f\u611f\u5185\u5bb9\u65f6&#xff0c;\u540e\u679c\u4e0d\u582a\u8bbe\u60f3\u3002<\/p>\n<h3>\u6b63\u786e\u7528\u6cd5&#xff1a;\u660e\u786e\u6307\u5b9a\u76ee\u6807\u6e90<\/h3>\n<p>\u6b63\u786e\u7684\u505a\u6cd5\u662f&#xff0c;\u5728\u53d1\u9001\u6d88\u606f\u65f6&#xff0c;\u660e\u786e\u6307\u5b9a\u63a5\u6536\u65b9\u7684\u57df\u540d&#xff08;\u5373\u76ee\u6807\u6e90&#xff09;&#xff0c;\u53ea\u5141\u8bb8\u53ef\u4fe1\u7684\u57df\u540d\u63a5\u6536\u6d88\u606f\u3002\u6bd4\u5982&#xff0c;a.com\u8981\u5411b.com\u7684iframe\u53d1\u9001\u6d88\u606f&#xff0c;\u5c31\u5e94\u8be5\u8fd9\u6837\u5199&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u6b63\u786e\u793a\u4f8b&#xff1a;\u53ea\u5411https:\/\/b.com\u53d1\u9001\u6d88\u606f<\/span><br \/>\n<span class=\"token keyword\">let<\/span> iframeWindow <span class=\"token operator\">&#061;<\/span> document<span class=\"token punctuation\">.<\/span><span class=\"token function\">getElementById<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;myIframe&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">.<\/span>contentWindow<span class=\"token punctuation\">;<\/span><br \/>\niframeWindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">postMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u7528\u6237\u4fe1\u606f&#xff1a;xxx&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;https:\/\/b.com&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u6837&#xff0c;\u53ea\u6709https:\/\/b.com\u7684\u7a97\u53e3\u80fd\u63a5\u6536\u6d88\u606f&#xff0c;\u5176\u4ed6\u57df\u540d\u7684\u7a97\u53e3\u5373\u4f7f\u6536\u5230\u6d88\u606f&#xff0c;\u6d4f\u89c8\u5668\u4e5f\u4f1a\u62d2\u7edd\u5904\u7406\u3002<\/p>\n<h3>\u4e3a\u4ec0\u4e48\u76ee\u6807\u6e90\u5fc5\u987b\u4e25\u683c\u6307\u5b9a&#xff1f;<\/h3>\n<p>\u6d4f\u89c8\u5668\u5bf9postMessage\u7684\u76ee\u6807\u6e90\u6709\u4e25\u683c\u6821\u9a8c&#xff1a;\u5982\u679c\u53d1\u9001\u65b9\u6307\u5b9a\u7684\u76ee\u6807\u6e90\u4e0e\u63a5\u6536\u65b9\u7684\u5b9e\u9645\u57df\u540d\u4e0d\u5339\u914d&#xff0c;\u63a5\u6536\u65b9\u4f1a\u5ffd\u7565\u8fd9\u6761\u6d88\u606f\u3002\u8fd9\u5c31\u50cf\u5bc4\u5feb\u9012\u65f6&#xff0c;\u4f60\u5fc5\u987b\u5199\u5bf9\u6536\u4ef6\u4eba\u7684\u5730\u5740&#xff0c;\u5426\u5219\u5feb\u9012\u4f1a\u88ab\u9000\u56de\u3002<\/p>\n<p>\u5982\u679c\u7528&#034;*&#034;&#xff0c;\u5c31\u76f8\u5f53\u4e8e\u201c\u5730\u5740\u968f\u4fbf\u586b\u201d&#xff0c;\u4efb\u4f55\u6536\u4ef6\u4eba\u90fd\u80fd\u6536\u5230&#xff0c;\u663e\u7136\u4e0d\u5b89\u5168\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>\u7528postMessage\u5b9e\u73b0\u8de8\u57df\u901a\u4fe1\u65f6&#xff0c;\u76ee\u6807\u6e90\u7684\u8bbe\u7f6e\u662f\u6838\u5fc3\u5b89\u5168\u70b9&#xff1a;<\/p>\n<li>\u7edd\u5bf9\u4e0d\u8981\u4f7f\u7528&#034;*&#034;\u4f5c\u4e3a\u76ee\u6807\u6e90&#xff0c;\u8fd9\u4f1a\u8ba9\u6d88\u606f\u66b4\u9732\u7ed9\u6240\u6709\u57df\u540d&#xff1b;<\/li>\n<li>\u59cb\u7ec8\u660e\u786e\u6307\u5b9a\u63a5\u6536\u65b9\u7684\u57df\u540d&#xff08;\u5982&#034;https:\/\/trusted.com&#034;&#xff09;&#xff0c;\u786e\u4fdd\u53ea\u6709\u53ef\u4fe1\u7684\u7a97\u53e3\u80fd\u63a5\u6536\u6d88\u606f&#xff1b;<\/li>\n<li>\u5373\u4f7f\u662f\u540c\u4e00\u516c\u53f8\u7684\u4e0d\u540c\u57df\u540d&#xff08;\u5982a.com\u548cb.com&#xff09;&#xff0c;\u4e5f\u8981\u4e25\u683c\u6307\u5b9a&#xff0c;\u907f\u514d\u6d88\u606f\u88ab\u540c\u516c\u53f8\u7684\u975e\u9884\u671f\u9875\u9762\u63a5\u6536\u3002<\/li>\n<h2>7 \u63a5\u53d7message&#xff1a;\u5fc5\u987b\u6821\u9a8c\u6570\u636e\u6765\u6e90<\/h2>\n<h3>\u63a5\u6536\u6d88\u606f\u7684\u201c\u4fe1\u4efb\u5371\u673a\u201d<\/h3>\n<p>\u5f53\u4e00\u4e2a\u9875\u9762\u901a\u8fc7addEventListener\u76d1\u542cmessage\u4e8b\u4ef6\u65f6&#xff0c;\u5b83\u4f1a\u6536\u5230\u6765\u81ea\u5404\u79cd\u7a97\u53e3\u7684\u6d88\u606f\u2014\u2014\u53ef\u80fd\u662f\u53ef\u4fe1\u7684\u5408\u4f5c\u7f51\u7ad9&#xff0c;\u4e5f\u53ef\u80fd\u662f\u6076\u610f\u7f51\u7ad9\u4f2a\u9020\u7684\u6d88\u606f\u3002\u5982\u679c\u4e0d\u9a8c\u8bc1\u6d88\u606f\u7684\u6765\u6e90&#xff0c;\u5c31\u53ef\u80fd\u88ab\u653b\u51fb\u8005\u6b3a\u9a97&#xff0c;\u6267\u884c\u5371\u9669\u64cd\u4f5c\u3002<\/p>\n<h3>\u9519\u8bef\u7528\u6cd5&#xff1a;\u6765\u8005\u4e0d\u62d2<\/h3>\n<p>\u5f88\u591a\u65b0\u624b\u4f1a\u76f4\u63a5\u5199\u4e00\u4e2a\u76d1\u542c\u4e8b\u4ef6&#xff0c;\u4e0d\u505a\u4efb\u4f55\u6765\u6e90\u6821\u9a8c&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u9519\u8bef\u793a\u4f8b&#xff1a;\u63a5\u6536\u6240\u6709\u6d88\u606f&#xff0c;\u4e0d\u6821\u9a8c\u6765\u6e90<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token keyword\">function<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u76f4\u63a5\u5904\u7406\u6d88\u606f&#xff0c;\u6bd4\u5982\u6267\u884c\u811a\u672c\u6216\u4fee\u6539\u9875\u9762<\/span><br \/>\n  <span class=\"token function\">eval<\/span><span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u6781\u5176\u5371\u9669&#xff01;<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u79cd\u4ee3\u7801\u5c31\u50cf\u201c\u4e0d\u67e5\u8eab\u4efd\u8bc1\u5c31\u5f00\u95e8\u201d&#xff0c;\u5982\u679c\u653b\u51fb\u8005\u53d1\u9001\u4e00\u6761\u5305\u542b\u6076\u610f\u4ee3\u7801\u7684\u6d88\u606f&#xff08;\u6bd4\u5982&#034;document.location&#061;&#039;https:\/\/evil.com&#039;&#034;&#xff09;&#xff0c;\u9875\u9762\u5c31\u4f1a\u6267\u884c\u8fd9\u6761\u4ee3\u7801&#xff0c;\u5bfc\u81f4\u8df3\u8f6c\u81f3\u6076\u610f\u7f51\u7ad9&#xff0c;\u6216\u88ab\u7a83\u53d6\u6570\u636e\u3002<\/p>\n<h3>\u6b63\u786e\u7528\u6cd5&#xff1a;\u5148\u9a8c\u660e\u6b63\u8eab<\/h3>\n<p>\u6b63\u786e\u7684\u505a\u6cd5\u662f&#xff0c;\u5728\u5904\u7406\u6d88\u606f\u524d&#xff0c;\u5148\u901a\u8fc7event.origin&#xff08;\u53d1\u9001\u6d88\u606f\u7684\u7a97\u53e3\u7684\u57df\u540d&#xff09;\u6821\u9a8c\u6765\u6e90&#xff0c;\u53ea\u5904\u7406\u6765\u81ea\u53ef\u4fe1\u57df\u540d\u7684\u6d88\u606f\u3002\u6bd4\u5982&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u6b63\u786e\u793a\u4f8b&#xff1a;\u6821\u9a8c\u6765\u6e90\u540e\u518d\u5904\u7406\u6d88\u606f<\/span><br \/>\n<span class=\"token keyword\">function<\/span> <span class=\"token function\">receiveMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token comment\">\/\/ \u53ea\u4fe1\u4efbhttps:\/\/trusted.com\u53d1\u9001\u7684\u6d88\u606f<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>origin <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token string\">&#034;https:\/\/trusted.com&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    console<span class=\"token punctuation\">.<\/span><span class=\"token function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u5ffd\u7565\u6765\u81ea\u672a\u77e5\u6765\u6e90\u7684\u6d88\u606f&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u4e0d\u662f\u53ef\u4fe1\u6765\u6e90&#xff0c;\u76f4\u63a5\u8fd4\u56de<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u5904\u7406\u53ef\u4fe1\u6765\u6e90\u7684\u6d88\u606f&#xff08;\u540c\u65f6\u6ce8\u610f\u8fc7\u6ee4\u6d88\u606f\u5185\u5bb9&#xff0c;\u9632\u6b62XSS&#xff09;<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>type <span class=\"token operator\">&#061;&#061;&#061;<\/span> <span class=\"token string\">&#034;updateUser&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token function\">updateUserInfo<\/span><span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u5b89\u5168\u5904\u7406<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<p><span class=\"token comment\">\/\/ \u7ed1\u5b9a\u76d1\u542c\u4e8b\u4ef6&#xff0c;\u6307\u5b9a\u5904\u7406\u51fd\u6570<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">addEventListener<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;message&#034;<\/span><span class=\"token punctuation\">,<\/span> receiveMessage<span class=\"token punctuation\">,<\/span> <span class=\"token boolean\">false<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u91cc\u7684event.origin\u4f1a\u8fd4\u56de\u53d1\u9001\u65b9\u7684\u57df\u540d&#xff08;\u5982&#034;https:\/\/trusted.com&#034;&#xff09;&#xff0c;\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5b83\u5224\u65ad\u6d88\u606f\u662f\u5426\u6765\u81ea\u53ef\u4fe1\u7684\u5408\u4f5c\u65b9\u3002<\/p>\n<h3>\u989d\u5916\u63d0\u9192&#xff1a;\u6821\u9a8c\u6d88\u606f\u5185\u5bb9\u683c\u5f0f<\/h3>\n<p>\u9664\u4e86\u6821\u9a8c\u6765\u6e90&#xff0c;\u8fd8\u5efa\u8bae\u6821\u9a8c\u6d88\u606f\u7684\u683c\u5f0f\u3002\u6bd4\u5982&#xff0c;\u7ea6\u5b9a\u6d88\u606f\u5fc5\u987b\u662f\u5305\u542btype\u548ccontent\u7684\u5bf9\u8c61&#xff0c;\u907f\u514d\u5904\u7406\u683c\u5f0f\u5f02\u5e38\u7684\u6d88\u606f&#xff1a;<\/p>\n<p><span class=\"token keyword\">function<\/span> <span class=\"token function\">receiveMessage<\/span><span class=\"token punctuation\">(<\/span><span class=\"token parameter\">event<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>origin <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token string\">&#034;https:\/\/trusted.com&#034;<\/span><span class=\"token punctuation\">)<\/span> <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u6821\u9a8c\u6d88\u606f\u683c\u5f0f<\/span><br \/>\n  <span class=\"token keyword\">if<\/span> <span class=\"token punctuation\">(<\/span><span class=\"token keyword\">typeof<\/span> event<span class=\"token punctuation\">.<\/span>data <span class=\"token operator\">!&#061;&#061;<\/span> <span class=\"token string\">&#034;object&#034;<\/span> <span class=\"token operator\">||<\/span> <span class=\"token operator\">!<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>type <span class=\"token operator\">||<\/span> <span class=\"token operator\">!<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    console<span class=\"token punctuation\">.<\/span><span class=\"token function\">log<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;\u6d88\u606f\u683c\u5f0f\u9519\u8bef&#xff0c;\u5ffd\u7565&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token keyword\">return<\/span><span class=\"token punctuation\">;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><\/p>\n<p>  <span class=\"token comment\">\/\/ \u6309\u7c7b\u578b\u5904\u7406\u6d88\u606f<\/span><br \/>\n  <span class=\"token keyword\">switch<\/span><span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>type<span class=\"token punctuation\">)<\/span> <span class=\"token punctuation\">{<\/span><br \/>\n    <span class=\"token keyword\">case<\/span> <span class=\"token string\">&#034;update&#034;<\/span><span class=\"token operator\">:<\/span><br \/>\n      <span class=\"token function\">handleUpdate<\/span><span class=\"token punctuation\">(<\/span>event<span class=\"token punctuation\">.<\/span>data<span class=\"token punctuation\">.<\/span>content<span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\n      <span class=\"token keyword\">break<\/span><span class=\"token punctuation\">;<\/span><br \/>\n    <span class=\"token comment\">\/\/ \u5176\u4ed6\u7c7b\u578b&#8230;<\/span><br \/>\n  <span class=\"token punctuation\">}<\/span><br \/>\n<span class=\"token punctuation\">}<\/span><\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>\u63a5\u6536message\u65f6&#xff0c;\u6821\u9a8c\u6765\u6e90\u662f\u9632\u6b62\u6076\u610f\u6d88\u606f\u7684\u5173\u952e&#xff1a;<\/p>\n<li>\u5fc5\u987b\u901a\u8fc7event.origin\u68c0\u67e5\u6d88\u606f\u53d1\u9001\u65b9\u7684\u57df\u540d&#xff0c;\u53ea\u5904\u7406\u53ef\u4fe1\u6765\u6e90\u7684\u6d88\u606f&#xff1b;<\/li>\n<li>\u540c\u65f6\u6821\u9a8c\u6d88\u606f\u7684\u683c\u5f0f&#xff0c;\u62d2\u7edd\u5904\u7406\u683c\u5f0f\u5f02\u5e38\u7684\u6d88\u606f&#xff1b;<\/li>\n<li>\u7edd\u5bf9\u4e0d\u8981\u76f4\u63a5\u6267\u884c\u6d88\u606f\u5185\u5bb9&#xff08;\u5982eval(event.data)&#xff09;&#xff0c;\u907f\u514d\u88ab\u6ce8\u5165\u6076\u610f\u4ee3\u7801\u3002 \u8bb0\u4f4f&#xff1a;\u201c\u4e0d\u660e\u6765\u6e90\u7684\u6d88\u606f&#xff0c;\u5c31\u50cf\u964c\u751f\u4eba\u9012\u6765\u7684\u996e\u6599&#xff0c;\u4e0d\u8981\u8f7b\u6613\u63a5\u53d7\u201d\u3002<\/li>\n<h2>8 \u7981\u6b62\u4f7f\u7528Web SQL\u6570\u636e\u5e93<\/h2>\n<h3>\u4ec0\u4e48\u662fWeb SQL\u6570\u636e\u5e93&#xff1f;<\/h3>\n<p>Web SQL\u6570\u636e\u5e93\u662fHTML5\u65e9\u671f\u63d0\u51fa\u7684\u4e00\u79cd\u672c\u5730\u6570\u636e\u5e93\u89e3\u51b3\u65b9\u6848&#xff0c;\u5141\u8bb8\u7f51\u9875\u901a\u8fc7SQL\u8bed\u53e5\u5728\u6d4f\u89c8\u5668\u4e2d\u5b58\u50a8\u548c\u64cd\u4f5c\u6570\u636e&#xff08;\u7c7b\u4f3cMySQL&#xff09;\u3002\u5b83\u7684\u4f7f\u7528\u65b9\u6cd5\u662f\u901a\u8fc7window.openDatabase\u521b\u5efa\u6216\u6253\u5f00\u6570\u636e\u5e93&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u521b\u5efa\u6216\u6253\u5f00Web SQL\u6570\u636e\u5e93<\/span><br \/>\n<span class=\"token keyword\">let<\/span> db <span class=\"token operator\">&#061;<\/span> window<span class=\"token punctuation\">.<\/span><span class=\"token function\">openDatabase<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;mydb&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;1.0&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token string\">&#034;\u6211\u7684\u6570\u636e\u5e93&#034;<\/span><span class=\"token punctuation\">,<\/span> <span class=\"token number\">2<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span> <span class=\"token operator\">*<\/span> <span class=\"token number\">1024<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u867d\u7136\u542c\u8d77\u6765\u5f88\u65b9\u4fbf&#xff0c;\u4f46\u5b9e\u9645\u4e0a&#xff0c;Web SQL\u6570\u636e\u5e93\u5df2\u7ecf\u88abW3C&#xff08;\u4e07\u7ef4\u7f51\u8054\u76df&#xff09;\u5e9f\u5f03&#xff0c;\u56e0\u4e3a\u5b83\u7684\u89c4\u8303\u4e0d\u591f\u7edf\u4e00&#xff0c;\u4e0d\u540c\u6d4f\u89c8\u5668\u7684\u5b9e\u73b0\u5dee\u5f02\u5f88\u5927\u3002<\/p>\n<h3>Web SQL\u6570\u636e\u5e93\u7684\u5b89\u5168\u98ce\u9669<\/h3>\n<p>\u9664\u4e86\u517c\u5bb9\u6027\u95ee\u9898&#xff0c;Web SQL\u6570\u636e\u5e93\u8fd8\u6709\u4e00\u4e2a\u4e25\u91cd\u7684\u5b89\u5168\u9690\u60a3&#xff1a;\u53ea\u8981\u77e5\u9053\u6570\u636e\u5e93\u7684\u540d\u79f0&#xff0c;\u540c\u4e00\u57df\u540d\u4e0b\u7684\u4efb\u4f55\u9875\u9762\u90fd\u80fd\u8bbf\u95ee\u5b83\u3002<\/p>\n<p>\u6bd4\u5982&#xff0c;a.com\u7684\u9875\u9762A\u521b\u5efa\u4e86\u4e00\u4e2a\u540d\u4e3auserdata\u7684Web SQL\u6570\u636e\u5e93&#xff0c;\u5b58\u50a8\u4e86\u7528\u6237\u7684\u9690\u79c1\u4fe1\u606f\u3002\u90a3\u4e48a.com\u7684\u53e6\u4e00\u4e2a\u9875\u9762B&#xff0c;\u53ea\u8981\u77e5\u9053\u6570\u636e\u5e93\u540d\u79f0\u662fuserdata&#xff0c;\u5c31\u80fd\u901a\u8fc7window.openDatabase\u6253\u5f00\u5e76\u8bfb\u53d6\u5176\u4e2d\u7684\u6570\u636e\u3002<\/p>\n<p>\u66f4\u5371\u9669\u7684\u662f&#xff0c;\u5982\u679ca.com\u5b58\u5728XSS\u6f0f\u6d1e&#xff0c;\u653b\u51fb\u8005\u53ef\u4ee5\u901a\u8fc7\u6ce8\u5165\u811a\u672c&#xff0c;\u8f7b\u677e\u83b7\u53d6\u6570\u636e\u5e93\u540d\u79f0\u5e76\u8bbf\u95ee\u5176\u4e2d\u7684\u6570\u636e&#xff0c;\u5bfc\u81f4\u4fe1\u606f\u6cc4\u9732\u3002<\/p>\n<h3>\u5982\u4f55\u68c0\u6d4b\u5e76\u907f\u514d\u4f7f\u7528&#xff1f;<\/h3>\n<p>\u5982\u679c\u4f60\u662f\u5f00\u53d1\u8005&#xff0c;\u68c0\u67e5\u4ee3\u7801\u4e2d\u662f\u5426\u5b58\u5728window.openDatabase\u2014\u2014\u53ea\u8981\u6709\u8fd9\u4e2a\u51fd\u6570\u8c03\u7528&#xff0c;\u5c31\u8bf4\u660e\u4f7f\u7528\u4e86Web SQL\u6570\u636e\u5e93&#xff0c;\u5b58\u5728\u98ce\u9669\u3002<\/p>\n<p>\u66ff\u4ee3\u65b9\u6848&#xff1a;\u4f7f\u7528IndexedDB&#xff08;\u53e6\u4e00\u79cdHTML5\u672c\u5730\u5b58\u50a8\u65b9\u6848&#xff09;&#xff0c;\u5b83\u7684\u5b89\u5168\u6027\u548c\u89c4\u8303\u6027\u66f4\u597d&#xff0c;\u4e14\u53d7\u540c\u6e90\u7b56\u7565\u4fdd\u62a4&#xff0c;\u8bbf\u95ee\u63a7\u5236\u66f4\u4e25\u683c\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>Web SQL\u6570\u636e\u5e93\u7531\u4e8e\u5b89\u5168\u98ce\u9669\u548c\u517c\u5bb9\u6027\u95ee\u9898&#xff0c;\u5df2\u88ab\u5e9f\u5f03&#xff0c;\u5f3a\u70c8\u5efa\u8bae\u7981\u6b62\u4f7f\u7528&#xff1a;<\/p>\n<li>\u68c0\u67e5\u4ee3\u7801\u4e2d\u662f\u5426\u6709window.openDatabase&#xff0c;\u5982\u6709\u5219\u7acb\u5373\u66ff\u6362&#xff1b;<\/li>\n<li>\u6539\u7528\u66f4\u5b89\u5168\u7684IndexedDB\u5b58\u50a8\u672c\u5730\u6570\u636e&#xff1b;<\/li>\n<li>\u5373\u4f7f\u4f7f\u7528\u66ff\u4ee3\u65b9\u6848&#xff0c;\u4e5f\u4e0d\u8981\u5b58\u50a8\u654f\u611f\u4fe1\u606f&#xff0c;\u672c\u5730\u5b58\u50a8\u59cb\u7ec8\u6709\u88ab\u7a83\u53d6\u7684\u98ce\u9669\u3002<\/li>\n<h2>9 \u9493\u9c7c\u98ce\u9669&#xff1a;window.open\u7684\u201c\u80cc\u540e\u4e00\u5200\u201d<\/h2>\n<h3>\u4ec0\u4e48\u662f\u9493\u9c7c\u653b\u51fb&#xff1f;<\/h3>\n<p>\u9493\u9c7c\u653b\u51fb\u662f\u6307\u653b\u51fb\u8005\u4f2a\u9020\u4e00\u4e2a\u4e0e\u5408\u6cd5\u7f51\u7ad9&#xff08;\u6bd4\u5982\u94f6\u884c\u3001\u8d2d\u7269\u5e73\u53f0&#xff09;\u9ad8\u5ea6\u76f8\u4f3c\u7684\u9875\u9762&#xff0c;\u8bf1\u9a97\u7528\u6237\u8f93\u5165\u8d26\u53f7\u5bc6\u7801\u7b49\u654f\u611f\u4fe1\u606f\u3002\u800cHTML5\u4e2d\u7684window.open\u51fd\u6570&#xff08;\u7528\u4e8e\u6253\u5f00\u65b0\u7a97\u53e3&#xff09;&#xff0c;\u5982\u679c\u4f7f\u7528\u4e0d\u5f53&#xff0c;\u5c31\u53ef\u80fd\u6210\u4e3a\u9493\u9c7c\u653b\u51fb\u7684\u201c\u5e2e\u51f6\u201d\u3002<\/p>\n<h3>window.open\u7684\u98ce\u9669\u573a\u666f<\/h3>\n<p>\u5047\u8bbe\u4f60\u5728A\u7f51\u7ad9&#xff08;a.com&#xff09;\u70b9\u51fb\u4e86\u4e00\u4e2a\u6309\u94ae&#xff0c;\u901a\u8fc7window.open\u6253\u5f00\u4e86B\u7f51\u7ad9&#xff08;b.com&#xff09;\u7684\u9875\u9762&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ A\u7f51\u7ad9\u7684\u4ee3\u7801&#xff1a;\u6253\u5f00B\u7f51\u7ad9<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span><span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;https:\/\/b.com&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u6b64\u65f6&#xff0c;B\u7f51\u7ad9\u7684\u9875\u9762\u53ef\u4ee5\u901a\u8fc7window.opener\u8bbf\u95eeA\u7f51\u7ad9\u7684\u7a97\u53e3\u5bf9\u8c61\u3002\u5982\u679cB\u7f51\u7ad9\u662f\u6076\u610f\u7684&#xff0c;\u5b83\u53ef\u4ee5\u901a\u8fc7window.opener.location\u4fee\u6539A\u7f51\u7ad9\u7684\u5730\u5740&#xff0c;\u6bd4\u5982&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ B\u7f51\u7ad9\u7684\u6076\u610f\u4ee3\u7801<\/span><br \/>\nwindow<span class=\"token punctuation\">.<\/span>opener<span class=\"token punctuation\">.<\/span>location <span class=\"token operator\">&#061;<\/span> <span class=\"token string\">&#034;https:\/\/fake-a.com&#034;<\/span><span class=\"token punctuation\">;<\/span> <span class=\"token comment\">\/\/ \u628aA\u7f51\u7ad9\u8df3\u8f6c\u5230\u4f2a\u9020\u7684\u9875\u9762<\/span><\/p>\n<p>\u8fd9\u65f6\u5019&#xff0c;\u7528\u6237\u539f\u672c\u7684A\u7f51\u7ad9\u9875\u9762\u4f1a\u88ab\u66ff\u6362\u6210\u4e00\u4e2a\u548cA\u7f51\u7ad9\u957f\u5f97\u4e00\u6a21\u4e00\u6837\u7684\u4f2a\u9020\u9875\u9762&#xff08;fake-a.com&#xff09;\u3002\u5f53\u7528\u6237\u4ee5\u4e3a\u8fd8\u5728A\u7f51\u7ad9\u4e0a\u64cd\u4f5c\u65f6&#xff0c;\u8f93\u5165\u7684\u8d26\u53f7\u5bc6\u7801\u5c31\u4f1a\u88ab\u653b\u51fb\u8005\u7a83\u53d6\u2014\u2014\u8fd9\u5c31\u662f\u5178\u578b\u7684\u201c\u9493\u9c7c\u201d\u3002<\/p>\n<h3>\u5982\u4f55\u9632\u5fa1\u9493\u9c7c\u98ce\u9669&#xff1f;<\/h3>\n<p>\u9632\u5fa1\u7684\u6838\u5fc3\u662f\u5207\u65adB\u7f51\u7ad9\u5bf9A\u7f51\u7ad9\u7684\u63a7\u5236&#xff0c;\u65b9\u6cd5\u5f88\u7b80\u5355&#xff1a;\u5728\u4f7f\u7528window.open\u6253\u5f00\u65b0\u7a97\u53e3\u540e&#xff0c;\u5c06window.opener\u8bbe\u4e3anull&#xff08;\u7a7a&#xff09;&#xff0c;\u8fd9\u6837\u65b0\u7a97\u53e3\u5c31\u65e0\u6cd5\u8bbf\u95ee\u539f\u7a97\u53e3\u4e86\u3002<\/p>\n<p>\u6b63\u786e\u7684\u4ee3\u7801&#xff1a;<\/p>\n<p><span class=\"token comment\">\/\/ \u6253\u5f00\u65b0\u7a97\u53e3\u540e&#xff0c;\u7acb\u5373\u5207\u65adopener\u5173\u8054<\/span><br \/>\n<span class=\"token keyword\">let<\/span> newWindow <span class=\"token operator\">&#061;<\/span> window<span class=\"token punctuation\">.<\/span><span class=\"token function\">open<\/span><span class=\"token punctuation\">(<\/span><span class=\"token string\">&#034;https:\/\/b.com&#034;<\/span><span class=\"token punctuation\">)<\/span><span class=\"token punctuation\">;<\/span><br \/>\nnewWindow<span class=\"token punctuation\">.<\/span>opener <span class=\"token operator\">&#061;<\/span> <span class=\"token keyword\">null<\/span><span class=\"token punctuation\">;<\/span><\/p>\n<p>\u8fd9\u6837&#xff0c;B\u7f51\u7ad9\u7684window.opener\u4f1a\u53d8\u6210null&#xff0c;\u65e0\u6cd5\u518d\u4fee\u6539A\u7f51\u7ad9\u7684\u5730\u5740&#xff0c;\u907f\u514d\u4e86\u9493\u9c7c\u98ce\u9669\u3002<\/p>\n<h3>\u989d\u5916\u63d0\u9192&#xff1a;\u8c28\u614e\u6253\u5f00\u4e0d\u53ef\u4fe1\u94fe\u63a5<\/h3>\n<p>\u5373\u4f7f\u505a\u4e86opener &#061; null\u7684\u5904\u7406&#xff0c;\u4e5f\u8981\u5c3d\u91cf\u907f\u514d\u6253\u5f00\u4e0d\u53ef\u4fe1\u7684\u7b2c\u4e09\u65b9\u94fe\u63a5\u3002\u56e0\u4e3a\u653b\u51fb\u8005\u53ef\u80fd\u4f1a\u5728\u65b0\u7a97\u53e3\u4e2d\u76f4\u63a5\u5c55\u793a\u4f2a\u9020\u9875\u9762&#xff0c;\u8bf1\u9a97\u7528\u6237\u64cd\u4f5c&#xff08;\u6bd4\u5982\u8ba9\u7528\u6237\u201c\u70b9\u51fb\u8fd4\u56de\u539f\u7f51\u7ad9\u201d&#xff0c;\u5b9e\u9645\u8df3\u8f6c\u5230\u9493\u9c7c\u9875&#xff09;\u3002<\/p>\n<h3>\u7ae0\u8282\u603b\u7ed3<\/h3>\n<p>window.open\u6253\u5f00\u65b0\u7a97\u53e3\u65f6&#xff0c;\u53ef\u80fd\u5b58\u5728\u9493\u9c7c\u98ce\u9669&#xff0c;\u6076\u610f\u7f51\u7ad9\u53ef\u901a\u8fc7window.opener\u7be1\u6539\u539f\u9875\u9762\u5730\u5740\u3002\u9632\u5fa1\u65b9\u6cd5&#xff1a;<\/p>\n<li>\u6253\u5f00\u65b0\u7a97\u53e3\u540e&#xff0c;\u7acb\u5373\u8bbe\u7f6enewWindow.opener &#061; null&#xff0c;\u5207\u65ad\u5173\u8054&#xff1b;<\/li>\n<li>\u5c3d\u91cf\u53ea\u6253\u5f00\u53ef\u4fe1\u6765\u6e90\u7684\u94fe\u63a5&#xff0c;\u5bf9\u7b2c\u4e09\u65b9\u94fe\u63a5\u4fdd\u6301\u8b66\u60d5&#xff1b;<\/li>\n<li>\u7f51\u7ad9\u81ea\u8eab\u8981\u52a0\u5f3a\u6807\u8bc6&#xff08;\u5982\u5b98\u65b9\u57df\u540d\u3001\u5b89\u5168\u9501\u56fe\u6807&#xff09;&#xff0c;\u5e2e\u52a9\u7528\u6237\u8bc6\u522b\u4f2a\u9020\u9875\u9762\u3002<\/li>\n<h2>\u5168\u6587\u603b\u7ed3<\/h2>\n<p>HTML5\u7684\u65b0\u7279\u6027\u4e3aWeb\u5f00\u53d1\u5e26\u6765\u4e86\u4fbf\u5229&#xff0c;\u4f46\u4e5f\u4f34\u968f\u7740\u591a\u6837\u7684\u5b89\u5168\u98ce\u9669\u3002\u5bf9\u4e8e\u5b89\u5168\u5c0f\u767d\u6765\u8bf4&#xff0c;\u638c\u63e1\u8fd9\u4e9b\u98ce\u9669\u7684\u6838\u5fc3\u9632\u5fa1\u539f\u5219\u81f3\u5173\u91cd\u8981&#xff1a;<\/p>\n<ul>\n<li>\u8f93\u5165\u8fc7\u6ee4&#xff1a;\u4efb\u4f55\u7528\u6237\u8f93\u5165\u6216\u7b2c\u4e09\u65b9\u5185\u5bb9&#xff0c;\u90fd\u8981\u7ecf\u8fc7\u8fc7\u6ee4&#xff08;\u5982XSS\u9632\u5fa1&#xff09;&#xff1b;<\/li>\n<li>\u6743\u9650\u6700\u5c0f\u5316&#xff1a;\u5982iframe\u7684sandbox\u5c5e\u6027&#xff0c;\u53ea\u5f00\u542f\u5fc5\u9700\u7684\u6743\u9650&#xff1b;<\/li>\n<li>\u6765\u6e90\u6821\u9a8c&#xff1a;\u8de8\u57df\u901a\u4fe1&#xff08;postMessage&#xff09;\u65f6&#xff0c;\u4e25\u683c\u9a8c\u8bc1\u53d1\u9001\u65b9\u548c\u63a5\u6536\u65b9\u7684\u57df\u540d&#xff1b;<\/li>\n<li>\u654f\u611f\u4fe1\u606f\u4fdd\u62a4&#xff1a;\u4e0d\u628a\u5bc6\u7801\u3001Token\u7b49\u5b58\u5230WebStorage\u6216Web SQL\u6570\u636e\u5e93&#xff1b;<\/li>\n<li>\u5207\u65ad\u4e0d\u5fc5\u8981\u5173\u8054&#xff1a;\u5982window.opener &#061; null&#xff0c;\u9632\u6b62\u9493\u9c7c\u653b\u51fb\u3002<\/li>\n<\/ul>\n<p>\u5b89\u5168\u9632\u62a4\u6ca1\u6709\u201c\u94f6\u5f39\u201d&#xff0c;\u4f46\u53ea\u8981\u5728\u5f00\u53d1\u4e2d\u6ce8\u610f\u8fd9\u4e9b\u7ec6\u8282&#xff0c;\u5c31\u80fd\u5927\u5e45\u964d\u4f4e\u98ce\u9669\u3002\u5e0c\u671b\u672c\u6587\u80fd\u5e2e\u52a9\u4f60\u8fc8\u51faHTML5\u5b89\u5168\u7684\u7b2c\u4e00\u6b65&#xff0c;\u8ba9\u4f60\u7684\u7f51\u9875\u65e2\u5f3a\u5927\u53c8\u5b89\u5168\u3002<\/p>\n<hr \/>\n<p>\u672c\u6587\u662f\u300cWeb\u5b89\u5168\u57fa\u7840\u300d\u7cfb\u5217\u7684\u7b2c 11 \u7bc7&#xff0c;\u70b9\u51fb\u4e13\u680f\u5bfc\u822a\u67e5\u770b\u5168\u90e8\u7cfb\u5217\u5185\u5bb9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u968f\u7740\u4e92\u8054\u7f51\u7684\u98de\u901f\u53d1\u5c55\uff0cHTML5\u4f5c\u4e3a\u6784\u5efaWeb\u9875\u9762\u7684\u6838\u5fc3\u6280\u672f\uff0c\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u2014\u2014\u4ece\u89c6\u9891\u64ad\u653e\u3001\u8de8\u57df\u901a\u4fe1\u5230\u672c\u5730\u6570\u636e\u5b58\u50a8\uff0cHTML5\u7684\u65b0\u7279\u6027\u8ba9\u7f51\u9875\u4e0d\u518d\u5c40\u9650\u4e8e\u7b80\u5355\u7684\u6587\u5b57\u548c\u56fe\u7247\u5c55\u793a\u3002\u4f46\u8fd9\u4e9b\u5f3a\u5927\u7684\u529f\u80fd\u5728\u4fbf\u5229\u6211\u4eec\u7684\u540c\u65f6\uff0c\u4e5f\u57cb\u4e0b\u4e86\u4e0d\u5c11\u5b89\u5168\u9690\u60a3\u3002HTML5\u7684\u5b89\u5168\u98ce\u9669\u5c31\u85cf\u5728\u65e5\u5e38\u5f00\u53d1\u7684\u7ec6\u8282\u91cc\uff1a\u4e00\u4e2a\u672a\u52a0\u9650\u5236\u7684iframe\u3001\u4e00\u6bb5\u6ca1\u505a\u6821\u9a8c\u7684\u8de8\u57df\u6d88\u606f\u3001\u4e00\u4e2a\u968f\u610f\u4f7f\u7528\u7684\u672c\u5730\u5b58\u50a8\u2026\u2026\u7a0d\u6709\u4e0d\u614e\uff0c\u5c31\u53ef\u80fd\u88ab\u653b\u51fb\u8005\u5229\u7528\uff0c\u5bfc\u81f4\u7528\u6237\u4fe1\u606f\u6cc4\u9732\u3001\u7f51\u9875\u88ab\u7be1\u6539\u751a\u81f3\u670d\u52a1\u5668\u88ab\u653b\u51fb\u3002<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[964,275,61,2961,122],"topic":[],"class_list":["post-52785","post","type-post","status-publish","format-standard","hentry","category-server","tag-html5","tag-web","tag-61","tag-2961","tag-122"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wsisp.com\/helps\/52785.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u968f\u7740\u4e92\u8054\u7f51\u7684\u98de\u901f\u53d1\u5c55\uff0cHTML5\u4f5c\u4e3a\u6784\u5efaWeb\u9875\u9762\u7684\u6838\u5fc3\u6280\u672f\uff0c\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u2014\u2014\u4ece\u89c6\u9891\u64ad\u653e\u3001\u8de8\u57df\u901a\u4fe1\u5230\u672c\u5730\u6570\u636e\u5b58\u50a8\uff0cHTML5\u7684\u65b0\u7279\u6027\u8ba9\u7f51\u9875\u4e0d\u518d\u5c40\u9650\u4e8e\u7b80\u5355\u7684\u6587\u5b57\u548c\u56fe\u7247\u5c55\u793a\u3002\u4f46\u8fd9\u4e9b\u5f3a\u5927\u7684\u529f\u80fd\u5728\u4fbf\u5229\u6211\u4eec\u7684\u540c\u65f6\uff0c\u4e5f\u57cb\u4e0b\u4e86\u4e0d\u5c11\u5b89\u5168\u9690\u60a3\u3002HTML5\u7684\u5b89\u5168\u98ce\u9669\u5c31\u85cf\u5728\u65e5\u5e38\u5f00\u53d1\u7684\u7ec6\u8282\u91cc\uff1a\u4e00\u4e2a\u672a\u52a0\u9650\u5236\u7684iframe\u3001\u4e00\u6bb5\u6ca1\u505a\u6821\u9a8c\u7684\u8de8\u57df\u6d88\u606f\u3001\u4e00\u4e2a\u968f\u610f\u4f7f\u7528\u7684\u672c\u5730\u5b58\u50a8\u2026\u2026\u7a0d\u6709\u4e0d\u614e\uff0c\u5c31\u53ef\u80fd\u88ab\u653b\u51fb\u8005\u5229\u7528\uff0c\u5bfc\u81f4\u7528\u6237\u4fe1\u606f\u6cc4\u9732\u3001\u7f51\u9875\u88ab\u7be1\u6539\u751a\u81f3\u670d\u52a1\u5668\u88ab\u653b\u51fb\u3002\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/52785.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-08-11T11:19:31+00:00\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52785.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/52785.html\",\"name\":\"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-08-11T11:19:31+00:00\",\"dateModified\":\"2025-08-11T11:19:31+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/52785.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/52785.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/52785.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wsisp.com\/helps\/52785.html","og_locale":"zh_CN","og_type":"article","og_title":"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb242\u6b21\u3002\u968f\u7740\u4e92\u8054\u7f51\u7684\u98de\u901f\u53d1\u5c55\uff0cHTML5\u4f5c\u4e3a\u6784\u5efaWeb\u9875\u9762\u7684\u6838\u5fc3\u6280\u672f\uff0c\u4e3a\u6211\u4eec\u5e26\u6765\u4e86\u66f4\u4e30\u5bcc\u7684\u529f\u80fd\u548c\u66f4\u6d41\u7545\u7684\u7528\u6237\u4f53\u9a8c\u2014\u2014\u4ece\u89c6\u9891\u64ad\u653e\u3001\u8de8\u57df\u901a\u4fe1\u5230\u672c\u5730\u6570\u636e\u5b58\u50a8\uff0cHTML5\u7684\u65b0\u7279\u6027\u8ba9\u7f51\u9875\u4e0d\u518d\u5c40\u9650\u4e8e\u7b80\u5355\u7684\u6587\u5b57\u548c\u56fe\u7247\u5c55\u793a\u3002\u4f46\u8fd9\u4e9b\u5f3a\u5927\u7684\u529f\u80fd\u5728\u4fbf\u5229\u6211\u4eec\u7684\u540c\u65f6\uff0c\u4e5f\u57cb\u4e0b\u4e86\u4e0d\u5c11\u5b89\u5168\u9690\u60a3\u3002HTML5\u7684\u5b89\u5168\u98ce\u9669\u5c31\u85cf\u5728\u65e5\u5e38\u5f00\u53d1\u7684\u7ec6\u8282\u91cc\uff1a\u4e00\u4e2a\u672a\u52a0\u9650\u5236\u7684iframe\u3001\u4e00\u6bb5\u6ca1\u505a\u6821\u9a8c\u7684\u8de8\u57df\u6d88\u606f\u3001\u4e00\u4e2a\u968f\u610f\u4f7f\u7528\u7684\u672c\u5730\u5b58\u50a8\u2026\u2026\u7a0d\u6709\u4e0d\u614e\uff0c\u5c31\u53ef\u80fd\u88ab\u653b\u51fb\u8005\u5229\u7528\uff0c\u5bfc\u81f4\u7528\u6237\u4fe1\u606f\u6cc4\u9732\u3001\u7f51\u9875\u88ab\u7be1\u6539\u751a\u81f3\u670d\u52a1\u5668\u88ab\u653b\u51fb\u3002","og_url":"https:\/\/www.wsisp.com\/helps\/52785.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-08-11T11:19:31+00:00","author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"9 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/52785.html","url":"https:\/\/www.wsisp.com\/helps\/52785.html","name":"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-08-11T11:19:31+00:00","dateModified":"2025-08-11T11:19:31+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/52785.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/52785.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/52785.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"\u3010Web\u5b89\u5168\u3011HTML5\u5b89\u5168\u57fa\u7840\u6307\u5357\uff1a\u4ece\u5165\u95e8\u5230\u907f\u5751\u2014\u2014\u5c0f\u767d\u4e5f\u80fd\u770b\u61c2\u7684\u5b89\u5168\u9632\u62a4\u624b\u518c"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52785","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=52785"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/52785\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=52785"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=52785"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=52785"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=52785"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}