{"id":12246,"date":"2026-07-09T10:54:11","date_gmt":"2026-07-09T02:54:11","guid":{"rendered":"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12246"},"modified":"2026-07-09T10:54:11","modified_gmt":"2026-07-09T02:54:11","slug":"sethtml-element-startviewtransition","status":"publish","type":"post","link":"https:\/\/www.zhangxinxu.com\/wordpress\/2026\/07\/sethtml-element-startviewtransition\/","title":{"rendered":"\u524d\u7aef\u5feb\u8baf\uff1asetHTML()\u548cElement.startViewTransition\u5df2\u652f\u6301"},"content":{"rendered":"<p>by <a href=\"https:\/\/www.zhangxinxu.com\/\">zhangxinxu<\/a> from <a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12246\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=12246<\/a><br \/>\n\u672c\u6587\u53ef\u5168\u6587\u8f6c\u8f7d\uff0c\u4f46\u9700\u8981\u4fdd\u7559\u539f\u4f5c\u8005\u3001\u51fa\u5904\u4ee5\u53ca\u6587\u4e2d\u94fe\u63a5\uff0cAI\u6293\u53d6\u4fdd\u7559\u539f\u6587\u5730\u5740\uff0c\u4efb\u4f55\u7f51\u7ad9\u5747\u53ef\u6458\u8981\u805a\u5408\uff0c\u5546\u7528\u8bf7\u8054\u7cfb\u6388\u6743\u3002<\/p>\n<h3>\u4e00\u3001\u5148\u8bf4setHTML\u65b9\u6cd5<\/h3>\n<p>\u4e4b\u524d\u6709\u4ecb\u7ecd\u8fc7<code>setHTMLUnsafe()<\/code>\u65b9\u6cd5\uff0c\u7a0d\u7b49\uff0c\u8ba9\u6211\u627e\u4e00\u4e0b\u3002<\/p>\n<p>\u627e\u5230\u4e86\uff0c\u5c31\u662f\u8fd9\u7bc7\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2025\/04\/dom-sethtmlunsafe-parsehtmlunsafe\/\">\u4ecb\u7ecd\u4e24\u4e2aDOM\u65b0\u65b9\u6cd5setHTMLUnsafe\u548cgetHTML<\/a><\/p>\n<p>\u662f\u53bb\u5e744\u6708\u4efd\u4ecb\u7ecd\u7684\uff0c\u8ddd\u4eca\u670915\u4e2a\u6708\u3002<\/p>\n<p>\u5f53\u65f6setHTML()\u65b9\u6cd5\u8fd8\u672a\u652f\u6301\uff0c\u8c01\u77e5\u624d\u6ca1\u8fc7\u591a\u4e45\uff0cChrome\u6d4f\u89c8\u5668\u5c31\u5df2\u7ecf\u652f\u6301\u4e86\u6b64\u7279\u6027\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_144741.png\" width=\"651\" height=\"232\" alt=\"setHTML\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<h4>\u5173\u4e8esetHTML<\/h4>\n<p><code>setHTML()<\/code>\u65b9\u6cd5\u8bbe\u7f6eHTML\u5b57\u7b26\u4e32\u5185\u5bb9\u7684\u65f6\u5019\uff0c\u4f1a\u81ea\u52a8\u8fdb\u884cXSS\u8fc7\u6ee4\uff0c\u4f1a\u81ea\u52a8\u79fb\u9664<code>&lt;script&gt;<\/code>\u3001<code>&lt;frame&gt;<\/code>\u3001<code>&lt;iframe&gt;<\/code>\u3001<code>&lt;embed&gt;<\/code>\u3001<code>&lt;object&gt;<\/code>\u3001<code>&lt;use&gt;<\/code>\u4ee5\u53ca\u4e8b\u4ef6\u5904\u7406\u7a0b\u5e8f\u5c5e\u6027\u3002<\/p>\n<p>\u800c<code>setHTMLUnsafe()<\/code>\u65b9\u6cd5\u5219\u4e0d\u4f1a\uff0c<code>setHTMLUnsafe()<\/code>\u65b9\u6cd5\u7684\u884c\u4e3a\u8868\u73b0\u66f4\u63a5\u8fd1\u4e8einnerHTML\u65b9\u6cd5\u3002<\/p>\n<p>\u4e3e\u4e2a\u4f8b\u5b50\uff1a<\/p>\n<pre>&lt;div id=\"container\"&gt;&lt;\/div&gt;\r\n\r\n&lt;p&gt;\r\n  &lt;button id=\"b1\"&gt;setHTML()\u65b9\u6cd5&lt;\/button&gt;\r\n  &lt;button id=\"b2\"&gt;setHTMLUnsafe()\u65b9\u6cd5&lt;\/button&gt;\r\n&lt;\/p&gt;<\/pre>\n<pre>const str = `&lt;script&gt;console.log('\u7cdf\u4e86\uff0c\u4e2d\u4e86\u5200\u76fe');&lt;\/script&gt;\r\n&lt;img src=\"book.webp\" onload=\"this.style.border= 'red solid'\"&gt;\r\n&lt;details&gt;\r\n    &lt;summary&gt;HTML\u5e76\u4e0d\u7b80\u5355&lt;\/summary&gt;\r\n    &lt;p&gt;\u611f\u8c22\u5927\u5bb6\u6b63\u7248\u652f\u6301\uff0c\u65e0\u8bba\u73af\u5883\u5982\u4f55\u53d8\u5316\uff0c\u5b66\u4e60\u603b\u662f\u4e0d\u8981\u505c\u6b62\u7684\u3002&lt;\/p&gt;\r\n&lt;\/details&gt;\r\n&lt;p&gt;\u666e\u901a\u6587\u5b57\u4e5f\u4e0d\u663e\u793a\uff1f&lt;\/p&gt;`;\r\n\r\nb1.onclick = () =&gt; {\r\n  container.setHTML(str);\r\n}\r\n\r\nb2.onclick = () =&gt; {\r\n  container.setHTMLUnsafe(str);\r\n}<\/pre>\n<p>\u7ed3\u679c\u6700\u7ec8\u7684\u8fd0\u884c\u7ed3\u679c\u8fdc\u8d85\u81ea\u5df1\u7684\u9884\u671f\uff01<\/p>\n<p>\u6211\u4e00\u5f00\u59cb\u9884\u4f30\u7684\u662f\uff1a<\/p>\n<ul>\n<li><code>&lt;script&gt;<\/code>\u5143\u7d20\u88ab\u8fc7\u6ee4\uff1b<\/li>\n<li><code>onload<\/code>\u5c5e\u6027\u8fc7\u6ee4\uff0c\u4f46\u662f\u56fe\u7247\u5143\u7d20\u4fdd\u7559\u3002<\/li>\n<li><code>&lt;details&gt;<\/code>\u5143\u7d20\u6b63\u5e38\u663e\u793a\uff0c\u518d\u9000\u4e00\u6b65\uff0c\u53ef\u80fd\u4ea4\u4e92\u529f\u80fd\u8fc7\u6ee4\uff0c\u53ea\u6709\u7eaf\u6587\u672c<\/li>\n<\/ul>\n<p><code>setHTML(str)<\/code>\u65b9\u6cd5\u6267\u884c\u540e\uff0ccontainer\u5bb9\u5668\u91cc\u9762\u552f\u4e00\u5b58\u6d3b\u7684\u5143\u7d20\u5c31\u662f<code>&lt;p&gt;<\/code>\u5143\u7d20\uff0c\u800c\u524d\u9762\u7684<code>&lt;script&gt;<\/code>\u3001<code>&lt;img&gt;<\/code>\u3001<code>&lt;details&gt;<\/code>\u5143\u7d20\u901a\u901a\u6d88\u5931\u4e0d\u89c1\u4e86\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_154454.png\" width=\"438\" height=\"106\" alt=\"setHTML\u8fc7\u6ee4\u8fd0\u884c\u7ed3\u679c\u793a\u610f\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u8fd9\u7279\u4e48\u8fc7\u6ee4\u7684\u4e5f\u592a\u72e0\u4e86\uff0c\u6839\u672c\u5c31\u6ca1\u6cd5\u4f7f\u7528\u4e86\uff01<\/p>\n<p><code>setHTMLUnsafe()<\/code>\u65b9\u6cd5\u5219\u7b26\u5408\u9884\u671f\uff0c\u56fe\u7247\u6b63\u5e38\u663e\u793a\uff0conload\u65b9\u6cd5\u4e5f\u6b63\u5e38\u6267\u884c\u4e86\uff0c<code>&lt;details&gt;<\/code>\u5143\u7d20\u7684\u5c55\u5f00\u4e0e\u6536\u8d77\u4ea4\u4e92\u4e5f\u662f\u6b63\u5e38\u7684\u3002<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_155921.webp\" width=\"196\" height=\"165\" alt=\"setHTMLUnsafe\u8fd0\u884c\u7ed3\u679c\u793a\u610f\" class=\"alignnone size-medium\" style=\"border:1px solid #eee\" \/><\/p>\n<h4>\u5cf0\u56de\u8def\u8f6c\uff0c\u53ef\u9009\u53c2\u6570<\/h4>\n<p>\u540e\u6765\u6211\u4e00\u770b\u6587\u6863\uff0c\u53d1\u73b0<code>setHTML()<\/code>\u65b9\u6cd5\u652f\u6301\u53ef\u9009\u53c2\u6570\uff0c\u53ef\u4ee5\u6307\u5b9a\u8fc7\u6ee4\u7684\u5143\u7d20\u548c\u5c5e\u6027\u3002<\/p>\n<p>\u6211\u5c31\u8bf4\u561b\uff0c\u600e\u4e48\u4f1a\u6709\u8bbe\u8ba1\u8fd9\u4e48\u9e21\u808b\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u4e0d\u8fc7\u8fd9\u4e2a\u53ef\u9009\u53c2\u6570\u8fd8\u4e0d\u592a\u597d\u7406\u89e3\uff0c\u79f0\u4e3aSanitizer \u6216\u8005 SanitizerConfig \u5bf9\u8c61\u3002<\/p>\n<p>\u55ef\u2026\u2026\u8fd9\u4e2a\u65f6\u5019\u6700\u5feb\u7684\u5b66\u4e60\u65b9\u6cd5\u5c31\u662f\u6848\u4f8b\u3002<\/p>\n<p>\u6bd4\u65b9\u8bf4\u5141\u8bb8\u7684\u53ef\u9009\u53c2\u6570\u793a\u610f\uff1a<\/p>\n<pre>const sanitizer = new Sanitizer({\r\n  elements: [\"div\", \"p\", \"script\"],\r\n  attributes: [\"id\"],\r\n  replaceWithChildrenElements: [\"b\"],\r\n  comments: true,\r\n  dataAttributes: false,\r\n});<\/pre>\n<p>\u79fb\u9664\u7684\u53c2\u6570\u793a\u610f\uff1a<\/p>\n<pre>const sanitizer = new Sanitizer({\r\n  removeElements: [\"span\", \"script\"],\r\n  removeAttributes: [\"lang\", \"id\"],\r\n  comments: false,\r\n});<\/pre>\n<p>\u56de\u5230\u8fd9\u91cc\uff0c\u5982\u679c\u6211\u5e0c\u671bsetHTML\u7684\u65f6\u5019\uff0c\u4ec5\u4ec5script\u5143\u7d20\u548conload\u5c5e\u6027\u88ab\u8fc7\u6ee4\uff0c\u53ef\u4ee5\u8fd9\u4e48\u8bbe\u7f6e\uff1a<\/p>\n<pre>const sanitizer = new Sanitizer({\r\n  removeElements: [\"script\"],\r\n  removeAttributes: [\"onload\"],\r\n});\r\n\r\ncontainer.setHTML(str, {\r\n  sanitizer\r\n});<\/pre>\n<p>\u6b64\u65f6\uff0ccontainer\u91cc\u9762\u7684\u5143\u7d20\u5448\u73b0\u5c31\u7b26\u5408\u9884\u671f\u4e86\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-9_102919.png\" width=\"622\" height=\"209\" class=\"alignnone size-medium\" alt=\"\u7b26\u5408\u9884\u671f\u7684setHTML\u6e32\u67d3\u7ed3\u679c\" class=\"alignnone size-medium\" style=\"border:1px solid #eee\" \/><\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202607\/js-dom-sethtml-demo.php\" rel=\"noopener\" target=\"_blank\">setHTML\u548csetHTMLUnsafe\u65b9\u6cd5\u6548\u679c\u5bf9\u6bd4demo<\/a><\/p>\n<h3>\u4e8c\u3001Element.startViewTransition\u6307\u7684\u662f\uff1f<\/h3>\n<p><code>startViewTransition<\/code>\u5176\u5b9e\u4e4b\u524d\u4e5f\u4ecb\u7ecd\u8fc7\uff0c\u662f\u8fd9\u7bc7\u6587\u7ae0\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2024\/08\/view-transitions-api\/\">\u9875\u9762\u7ea7\u53ef\u89c6\u52a8\u753bView Transitions API\u521d\u4f53\u9a8c<\/a><\/p>\n<p>\u770b\u4e86\u4e0b\u53d1\u5e03\u65e5\u671f\uff0c\u662f\u4e24\u5e74\u524d\u7684\u4f5c\u54c1\u4e86\u3002<\/p>\n<p>\u4e0d\u8fc7\u90a3\u4e2a\u65f6\u5019<code>startViewTransition<\/code>\u53ea\u80fd\u5728document\u6587\u6863\u5bf9\u8c61\u4e2d\u8c03\u7528\uff0c\u4e5f\u5c31\u662f\u53ea\u80fd\u662f\u9875\u9762\u7ea7\u7684\u53ef\u89c6\u8fc7\u6e21\u6548\u679c\u3002<\/p>\n<p>\u73b0\u5728<code>startViewTransition<\/code> API\u7684\u5e94\u7528\u8303\u56f4\u518d\u6b21\u5347\u7ea7\uff0c\u53ef\u4ee5\u5728\u4efb\u610f\u7684HTML\u5143\u7d20DOM\u4e0a\u8c03\u7528\u3002<\/p>\n<p>\u5148\u770b\u517c\u5bb9\u6027\uff0c\u540c\u6837\u76ee\u524d\u4ec5Chrome\u6d4f\u89c8\u5668\u652f\u6301\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_164154.png\" width=\"649\" height=\"239\" alt=\"Element.startViewTransition\u517c\u5bb9\u6027\" class=\"alignnone size-medium\" \/><\/p>\n<p><code>startViewTransition<\/code>\u53ef\u4ee5\u8ba9\u5143\u7d20\u72b6\u6001\u53d1\u751f\u53d8\u5316\u7684\u65f6\u5019\u5929\u7136\u4ea7\u751f\u52a8\u753b\u6548\u679c\uff0c\u800c\u4e0d\u9700\u8981\u989d\u5916\u8fdb\u884cCSS\u8bbe\u7f6e\uff08\u5f53\u7136\uff0cCSS\u8bbe\u7f6e\u4e5f\u662f\u53ef\u4ee5\u7684\uff0c\u4f46\u4e0d\u662f\u5fc5\u987b\u7684\uff09\u3002<\/p>\n<p>\u4e3e\u4e2a\u7b80\u5355\u7684\u4f8b\u5b50\uff0c\u70b9\u51fb\u67d0\u4e2a\u6309\u94ae\uff0c\u5220\u9664\u5143\u7d20\u3002<\/p>\n<p>\u5982\u679c\u6211\u4eec\u76f4\u63a5\u4f7f\u7528<code>Elememt.remove()<\/code>\u65b9\u6cd5\uff0c\u5143\u7d20\u4f1a\u7a81\u7136\u5676\u6389\uff0c\u5c31\u50cf\u8dcc\u843d\u7684\u80a1\u4ef7\u4ee4\u4eba\u731d\u4e0d\u53ca\u9632\u3002<\/p>\n<p>\u4f46\u662f\u5728<code>startViewTransition()<\/code>\u56de\u8c03\u4e2d\u8c03\u7528\uff0c\u5219\u81ea\u7136\u800c\u7136\u4f1a\u6709\u8fc7\u6e21\u52a8\u753b\u6548\u679c\u3002<\/p>\n<p>\u773c\u89c1\u4e3a\u5b9e\uff0c\u60a8\u53ef\u4ee5\u72e0\u72e0\u5730\u70b9\u51fb\u8fd9\u91cc\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/study\/202607\/js-element-startviewtransition-demo.php\" rel=\"noopener\" target=\"_blank\">Element.startViewTransition\u65b9\u6cd5demo\u6f14\u793a<\/a><\/p>\n<pre>container.startViewTransition(() =&gt; {\r\n  img.remove();\r\n});<\/pre>\n<p>\u6548\u679cGIF\uff1a<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/image-remove-transition.gif\" width=\"250\" height=\"156\" alt=\"remove\u65f6\u5019\u6709\u6de1\u5165\u6de1\u51fa\u6548\u679c\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c<code>startViewTransition()<\/code>\u65b9\u6cd5\u53ea\u80fd\u8bbe\u7f6e\u5728\u9700\u8981\u8fdb\u884c\u52a8\u753b\u6548\u679c\u7684\u5bb9\u5668\u5143\u7d20\u4e0a\uff0c\u8bbe\u7f6e\u5728\u5f53\u524d\u5143\u7d20\u4e0a\u662f\u65e0\u6548\u7684\u3002<\/p>\n<p>\u76f8\u6bd4\u5168\u5c40\u7684code>document.startViewTransition()<\/code>\u65b9\u6cd5\uff0c<code>Element.startViewTransition()<\/code>\u63a7\u5236\u8303\u56f4\u66f4\u7cbe\u51c6\uff0c\u901a\u5e38\u800c\u8a00\uff0c\u6027\u80fd\u4e5f\u66f4\u9ad8\u3002<\/p>\n<p>\u540c\u6837\u7684\uff0c\u6b64\u5904\u7684\u53ef\u89c6\u8fc7\u6e21\u6548\u679c\u4e5f\u652f\u6301\u4f7f\u7528<code>::view-transition-group<\/code>\u7b49\u4f2a\u5143\u7d20\u8fdb\u884c\u7c7b\u4f3c\u4e8e\u8fc7\u6e21\u65f6\u957f\uff0c\u7c7b\u578b\u7b49\u6548\u679c\u7684\u8bbe\u7f6e\u3002<\/p>\n<p>\u5177\u4f53\u53c2\u89c1\u4e4b\u524d\u64b0\u5199\u7684<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/2024\/08\/view-transitions-api\/\">\u8fd9\u7bc7\u6587\u7ae0<\/a>\uff0c\u8fd9\u91cc\u4e0d\u518d\u8d58\u8ff0\u3002<\/p>\n<h3>\u4e09\u3001\u603b\u7ed3\u4e00\u4e0b<\/h3>\n<p>\u672c\u6587\u4ecb\u7ecd\u4e86\u4e24\u4e2aDOM\u65b0\u7279\u6027\u90fd\u8fd8\u7b97\u6709\u4e0d\u9519\u7684\u5e94\u7528\u4ef7\u503c\uff0c\u4e0d\u8fc7\u53d7\u5236\u4e8e\u517c\u5bb9\u6027\uff0c\u77ed\u671f\u8fd8\u662f\u770b\u4e0d\u5230\u5728\u751f\u4ea7\u73af\u5883\u5e94\u7528\u7684\u53ef\u80fd\u6027\u3002<\/p>\n<p>\u76ee\u524d\u5927\u5bb6\u4e86\u89e3\u4e0b\u5373\u53ef\u3002<\/p>\n<p>\u6700\u540e\u8fd8\u6709\u70b9\u95f2\u529f\u592b\uff0c\u5206\u4eab\u4e0b\u4e0a\u5468\u81ea\u9a7e\u6e38\u4e00\u4ef6\u5e78\u8fd0\u7684\u4e8b\u60c5\u3002<\/p>\n<p>\u53bb\u76d0\u57ce\u4e2d\u534e\u9e8b\u9e7f\u56ed\u770b\u9e8b\u9e7f\u7684\uff0c\u7ed3\u679c\u7834\u5929\u8352\u5076\u9047\u9e7f\u738b\u4e89\u9738\uff0c\u76ee\u7779\u5168\u7a0b\u8fd110\u5206\u949f\u7684\u706b\u62fc\uff0c\u9e7f\u89d2\u78b0\u649e\u7684\u65f6\u5019\u54d0\u54d0\u4f5c\u54cd\uff0c\u6700\u540e\u6253\u5230\u53cc\u773c\u8840\u7ea2\uff0c\u53cc\u53cc\u53e3\u5410\u9c9c\u8840\uff0c\u771f\u662f\u5f80\u6b7b\u91cc\u5e72\u554a\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_171144.webp\" width=\"240\" height=\"254\" alt=\"\u9e7f\u738b\u4e89\u9738\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u4e0d\u8fc7\u4eba\u54c1\u662f\u5b88\u6052\u7684\uff0c\u6211\u5df2\u7ecf\u5f00\u59cb\u62c5\u5fc3\u6211\u63a5\u4e0b\u6765\u7684\u9493\u9c7c\u6536\u83b7\u4f1a\u4e0d\u4f1a\u53d8\u5f97\u60e8\u6de1\u4e86\u3002<\/p>\n<p>\u6700\u540e\uff0c\u5357\u5bab\u9619\u5e08\u59d0\u538b\u8f74\uff01<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-6_170809.webp\" width=\"342\" height=\"192\" alt=\"\u5357\u5bab\u9619\" class=\"alignnone size-medium\" \/><\/p>\n<p>\u672c\u6587\u4e3a\u539f\u521b\u6587\u7ae0\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0\u77e5\u8bc6\u70b9\u4ee5\u53ca\u4fee\u6b63\u4e00\u4e9b\u9519\u8bef\uff0c\u56e0\u6b64\u8f6c\u8f7d\u8bf7\u4fdd\u7559\u539f\u51fa\u5904\uff0c\u65b9\u4fbf\u6eaf\u6e90\uff0c\u907f\u514d\u9648\u65e7\u9519\u8bef\u77e5\u8bc6\u7684\u8bef\u5bfc\uff0c\u540c\u65f6\u6709\u66f4\u597d\u7684\u9605\u8bfb\u4f53\u9a8c\u3002<br \/>\n\u672c\u6587\u5730\u5740\uff1a<a href=\"https:\/\/www.zhangxinxu.com\/wordpress\/?p=12246\">https:\/\/www.zhangxinxu.com\/wordpress\/?p=12246<\/a><\/p>\n<p>\uff08\u672c\u7bc7\u5b8c\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/image.zhangxinxu.com\/image\/blog\/202607\/2026-7-9_104516.webp\" width=\"160\" height=\"100\" alt=\"\u5c01\u9762\u56fe\" class=\"alignright size-medium\" \/><\/p>\n<p>\u4e4b\u524d\u6709setHTMLUnsafe()\uff0c\u73b0\u5728\u65b0\u589e\u4e86setHTML()\u65b9\u6cd5\uff0c\u524d\u6709document.startViewTransition()\uff0c\u73b0\u5728\u589e\u5f3a\u4e3a\u5143\u7d20\u4e5f\u652f\u6301startViewTransition\u65b9\u6cd5\uff0c\u90fd\u6765\u770b\u770b\u4ed6\u4eec\u7684\u4f5c\u7528\u5427\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1284],"tags":[1207,613,2050,2133,2134,2125,2049,2126,1989],"_links":{"self":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12246"}],"collection":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/comments?post=12246"}],"version-history":[{"count":8,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12246\/revisions"}],"predecessor-version":[{"id":12319,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/posts\/12246\/revisions\/12319"}],"wp:attachment":[{"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/media?parent=12246"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/categories?post=12246"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.zhangxinxu.com\/wordpress\/wp-json\/wp\/v2\/tags?post=12246"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}