{"id":25686,"date":"2024-11-24T11:52:22","date_gmt":"2024-11-24T03:52:22","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25686\/"},"modified":"2024-11-24T11:52:22","modified_gmt":"2024-11-24T03:52:22","slug":"%e5%af%8c%e6%96%87%e6%9c%ac%e7%bc%96%e8%be%91%e5%99%a8%e7%9a%84%e6%96%b0%e7%ba%aa%e5%85%83%ef%bc%9adocument-execcommand-%e5%bc%83%e7%94%a8%ef%bc%8c%e5%a6%82%e4%bd%95%e9%80%89%e6%8b%a9%e6%9c%80-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25686\/","title":{"rendered":"\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u65b0\u7eaa\u5143\uff1adocument.execCommand \u5f03\u7528\uff0c\u5982\u4f55\u9009\u62e9\u6700\u4f73\u66ff\u4ee3\u65b9\u6848\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173068165120421.jpg\" class=\"aligncenter\" title=\"\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u65b0\u7eaa\u5143\uff1adocument.execCommand \u5f03\u7528\uff0c\u5982\u4f55\u9009\u62e9\u6700\u4f73\u66ff\u4ee3\u65b9\u6848\uff1f\u63d2\u56fe\" alt=\"\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u65b0\u7eaa\u5143\uff1adocument.execCommand \u5f03\u7528\uff0c\u5982\u4f55\u9009\u62e9\u6700\u4f73\u66ff\u4ee3\u65b9\u6848\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>api execcommand \u5f03\u7528\uff1a\u66ff\u4ee3\u65b9\u6848\u63a2\u7d22<\/strong><\/p>\n<p>document.execCommand API \u5df2\u88ab\u5f03\u7528\uff0c\u5f00\u53d1\u8005\u9700\u8981\u5bfb\u627e\u66ff\u4ee3\u65b9\u6848\u6765\u5b9e\u73b0\u5bf9\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u63a7\u5236\u3002\u672c\u6587\u5c06\u63a2\u8ba8 execCommand \u8fc7\u65f6\u7684\u539f\u56e0\u4ee5\u53ca\u53ef\u7528\u7684\u66ff\u4ee3\u54c1\u3002<\/p>\n<p><strong>execCommand \u7684\u7f3a\u70b9<\/strong><\/p>\n<p>document.execCommand \u5e76\u975e\u6807\u51c6\u5316 API\uff0c\u6d4f\u89c8\u5668\u51fa\u4e8e\u517c\u5bb9\u6027\u8003\u8651\u5bf9\u5176\u63d0\u4f9b\u652f\u6301\u3002\u7136\u800c\uff0c\u5b83\u5b58\u5728\u4e00\u4e9b\u56fa\u6709\u7f3a\u70b9\uff1a<\/p>\n<ul>\n<li> <strong>\u5b89\u5168\u6027\u95ee\u9898\uff1a<\/strong>execCommand \u53ef\u7528\u4e8e\u6267\u884c\u5bf9\u654f\u611f\u4fe1\u606f\u7684\u64cd\u4f5c\uff0c\u5bfc\u81f4\u5b89\u5168\u6f0f\u6d1e\u3002<\/li>\n<\/ul>\n<p><strong>\u66ff\u4ee3\u65b9\u6848<\/strong><\/p>\n<p>\u76ee\u524d\u8fd8\u6ca1\u6709\u76f4\u63a5\u66ff\u4ee3 execCommand \u7684\u6807\u51c6\u5316 API\u3002\u7136\u800c\uff0c\u6709\u4ee5\u4e0b\u66ff\u4ee3\u65b9\u6848\u53ef\u4f9b\u8003\u8651\uff1a<\/p>\n<ul>\n<li> <strong>\u57fa\u4e8e\u6d4f\u89c8\u5668\u7684 API\uff1a<\/strong>\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u63d0\u4f9b\u81ea\u5df1\u7684\u975e\u6807\u51c6\u5316 API\uff0c\u4f8b\u5982 Chrome \u7684 execCommandForElement()\u3002<\/li>\n<li> <strong>\u7b2c\u4e09\u65b9\u5e93\uff1a<\/strong>\u5b58\u5728\u8bb8\u591a\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982 Quill.js \u548c TinyMCE\uff0c\u5b83\u4eec\u63d0\u4f9b\u5bf9\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u5168\u9762\u63a7\u5236\u3002<\/li>\n<li> <strong>\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff1a<\/strong>\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u6784\u5efa\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff0c\u4f7f\u7528 DOM \u64cd\u4f5c\u548c\u4e8b\u4ef6\u76d1\u542c\u5668\u6765\u5b9e\u73b0\u7f16\u8f91\u529f\u80fd\u3002<\/li>\n<\/ul>\n<p><strong>\u5efa\u8bae<\/strong><\/p>\n<p>\u5bf9\u4e8e\u5bfb\u6c42\u5f00\u53d1\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u5f00\u53d1\u8005\uff0c\u5efa\u8bae\u91c7\u7528\u4ee5\u4e0b\u7b56\u7565\uff1a<\/p>\n<ul>\n<li> <strong>\u8003\u8651\u7b2c\u4e09\u65b9\u5e93\uff1a<\/strong>\u7b2c\u4e09\u65b9\u5e93\u63d0\u4f9b\u4e86\u5bf9\u7f16\u8f91\u5668\u529f\u80fd\u7684\u5373\u65f6\u8bbf\u95ee\uff0c\u7b80\u5316\u4e86\u5f00\u53d1\u8fc7\u7a0b\u3002<\/li>\n<li> <strong>\u6269\u5c55\u5f00\u6e90\u7f16\u8f91\u5668\uff1a<\/strong>\u57fa\u4e8e\u6210\u719f\u7684\u5f00\u6e90\u7f16\u8f91\u5668\uff08\u5982 CKEditor\uff09\u8fdb\u884c\u6269\u5c55\uff0c\u53ef\u4ee5\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002<\/li>\n<li> <strong>\u6743\u8861\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff1a<\/strong>\u5982\u679c\u73b0\u6709\u89e3\u51b3\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8003\u8651\u6784\u5efa\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u9700\u8981\u8003\u8651\u989d\u5916\u7684\u5f00\u53d1\u548c\u7ef4\u62a4\u6210\u672c\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u65b0\u7eaa\u5143\uff1adocument.execCommand \u5f03\u7528\uff0c\u5982\u4f55\u9009\u62e9\u6700\u4f73\u66ff\u4ee3\u65b9\u6848\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>api execcommand \u5f03\u7528\uff1a\u66ff\u4ee3\u65b9\u6848\u63a2\u7d22 document.execCommand API \u5df2\u88ab\u5f03\u7528\uff0c\u5f00\u53d1\u8005\u9700\u8981\u5bfb\u627e\u66ff\u4ee3\u65b9\u6848\u6765\u5b9e\u73b0\u5bf9\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u63a7\u5236\u3002\u672c\u6587\u5c06\u63a2\u8ba8 execCommand \u8fc7\u65f6\u7684\u539f\u56e0\u4ee5\u53ca\u53ef\u7528\u7684\u66ff\u4ee3\u54c1\u3002 execCommand \u7684\u7f3a\u70b9 document.execCommand \u5e76\u975e\u6807\u51c6\u5316 API\uff0c\u6d4f\u89c8\u5668\u51fa\u4e8e\u517c\u5bb9\u6027\u8003\u8651\u5bf9\u5176\u63d0\u4f9b\u652f\u6301\u3002\u7136\u800c\uff0c\u5b83\u5b58\u5728\u4e00\u4e9b\u56fa\u6709\u7f3a\u70b9\uff1a \u5b89\u5168\u6027\u95ee\u9898\uff1aexecCommand \u53ef\u7528\u4e8e\u6267\u884c\u5bf9\u654f\u611f\u4fe1\u606f\u7684\u64cd\u4f5c\uff0c\u5bfc\u81f4\u5b89\u5168\u6f0f\u6d1e\u3002 \u66ff\u4ee3\u65b9\u6848 \u76ee\u524d\u8fd8\u6ca1\u6709\u76f4\u63a5\u66ff\u4ee3 execCommand \u7684\u6807\u51c6\u5316 API\u3002\u7136\u800c\uff0c\u6709\u4ee5\u4e0b\u66ff\u4ee3\u65b9\u6848\u53ef\u4f9b\u8003\u8651\uff1a \u57fa\u4e8e\u6d4f\u89c8\u5668\u7684 API\uff1a\u4e0d\u540c\u7684\u6d4f\u89c8\u5668\u63d0\u4f9b\u81ea\u5df1\u7684\u975e\u6807\u51c6\u5316 API\uff0c\u4f8b\u5982 Chrome \u7684 execCommandForElement()\u3002 \u7b2c\u4e09\u65b9\u5e93\uff1a\u5b58\u5728\u8bb8\u591a\u7b2c\u4e09\u65b9\u5e93\uff0c\u5982 Quill.js \u548c TinyMCE\uff0c\u5b83\u4eec\u63d0\u4f9b\u5bf9\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u5168\u9762\u63a7\u5236\u3002 \u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff1a\u5f00\u53d1\u4eba\u5458\u53ef\u4ee5\u6784\u5efa\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff0c\u4f7f\u7528 DOM \u64cd\u4f5c\u548c\u4e8b\u4ef6\u76d1\u542c\u5668\u6765\u5b9e\u73b0\u7f16\u8f91\u529f\u80fd\u3002 \u5efa\u8bae \u5bf9\u4e8e\u5bfb\u6c42\u5f00\u53d1\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u5f00\u53d1\u8005\uff0c\u5efa\u8bae\u91c7\u7528\u4ee5\u4e0b\u7b56\u7565\uff1a \u8003\u8651\u7b2c\u4e09\u65b9\u5e93\uff1a\u7b2c\u4e09\u65b9\u5e93\u63d0\u4f9b\u4e86\u5bf9\u7f16\u8f91\u5668\u529f\u80fd\u7684\u5373\u65f6\u8bbf\u95ee\uff0c\u7b80\u5316\u4e86\u5f00\u53d1\u8fc7\u7a0b\u3002 \u6269\u5c55\u5f00\u6e90\u7f16\u8f91\u5668\uff1a\u57fa\u4e8e\u6210\u719f\u7684\u5f00\u6e90\u7f16\u8f91\u5668\uff08\u5982 CKEditor\uff09\u8fdb\u884c\u6269\u5c55\uff0c\u53ef\u4ee5\u6ee1\u8db3\u7279\u5b9a\u7684\u9700\u6c42\u3002 \u6743\u8861\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff1a\u5982\u679c\u73b0\u6709\u89e3\u51b3\u65b9\u6848\u65e0\u6cd5\u6ee1\u8db3\u9700\u6c42\uff0c\u5f00\u53d1\u8005\u53ef\u4ee5\u8003\u8651\u6784\u5efa\u81ea\u5df1\u7684\u81ea\u5b9a\u4e49\u89e3\u51b3\u65b9\u6848\uff0c\u4f46\u9700\u8981\u8003\u8651\u989d\u5916\u7684\u5f00\u53d1\u548c\u7ef4\u62a4\u6210\u672c\u3002 \u4ee5\u4e0a\u5c31\u662f\u5bcc\u6587\u672c\u7f16\u8f91\u5668\u7684\u65b0\u7eaa\u5143\uff1adocument.execCommand \u5f03\u7528\uff0c\u5982\u4f55\u9009\u62e9\u6700\u4f73\u66ff\u4ee3\u65b9\u6848\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-25686","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25686","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=25686"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25686\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25686"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25686"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25686"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}