{"id":1361,"date":"2019-09-03T15:58:58","date_gmt":"2019-09-03T07:58:58","guid":{"rendered":"http:\/\/www.iooe.cn\/?p=1361"},"modified":"2019-09-03T15:58:58","modified_gmt":"2019-09-03T07:58:58","slug":"js%e8%bd%ac%e6%8d%a2html%e8%bd%ac%e4%b9%89%e7%ac%a6-%e8%bf%99%e4%b8%aa%e6%af%94%e8%be%83%e5%a5%bd%e7%94%a8","status":"publish","type":"post","link":"http:\/\/www.iooe.cn\/index.php\/2019\/09\/03\/js%e8%bd%ac%e6%8d%a2html%e8%bd%ac%e4%b9%89%e7%ac%a6-%e8%bf%99%e4%b8%aa%e6%af%94%e8%be%83%e5%a5%bd%e7%94%a8\/","title":{"rendered":"JS\u8f6c\u6362HTML\u8f6c\u4e49\u7b26 \u8fd9\u4e2a\u6bd4\u8f83\u597d\u7528"},"content":{"rendered":"<h1>\n\t<a href=\"https:\/\/www.cnblogs.com\/leejersey\/p\/4568092.html\" id=\"cb_post_title_url\">JS\u8f6c\u6362HTML\u8f6c\u4e49\u7b26<\/a><br \/>\n<\/h1>\n<p>\n\t\/\/\u53bb\u6389html\u6807\u7b7e\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>removeHtmlTab(tab) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>tab.replace(\/&lt;[^<>]+?&gt;\/g,<\/code><code>&#39;&#39;<\/code><code>);<\/code><code>\/\/\u5220\u9664\u6240\u6709HTML\u6807\u7b7e<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/\u666e\u901a\u5b57\u7b26\u8f6c\u6362\u6210\u8f6c\u610f\u7b26\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>html2Escape(sHtml) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>sHtml.replace(\/[&lt;&gt;&amp;<\/code><code>&quot;]\/g,function(c){return {&#39;&lt;&#39;:&#39;&amp;lt;&#39;,&#39;&gt;&#39;:&#39;&amp;gt;&#39;,&#39;&amp;&#39;:&#39;&amp;amp;&#39;,&#39;&quot;<\/code><code>&#39;:<\/code><code>&#39;&amp;quot;&#39;<\/code><code>}[c];});<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/\u8f6c\u610f\u7b26\u6362\u6210\u666e\u901a\u5b57\u7b26\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t4\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>escape2Html(str) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>var<\/code>&nbsp;<code>arrEntities={<\/code><code>&#39;lt&#39;<\/code><code>:<\/code><code>&#39;&lt;&#39;<\/code><code>,<\/code><code>&#39;gt&#39;<\/code><code>:<\/code><code>&#39;&gt;&#39;<\/code><code>,<\/code><code>&#39;nbsp&#39;<\/code><code>:<\/code><code>&#39; &#39;<\/code><code>,<\/code><code>&#39;amp&#39;<\/code><code>:<\/code><code>&#39;&amp;&#39;<\/code><code>,<\/code><code>&#39;quot&#39;<\/code><code>:<\/code><code>&#39;&quot;&#39;<\/code><code>};<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>str.replace(\/&amp;(lt|gt|nbsp|amp|quot);\/ig,<\/code><code>function<\/code><code>(all,t){<\/code><code>return<\/code>&nbsp;<code>arrEntities[t];});<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/ &amp;nbsp;\u8f6c\u6210\u7a7a\u683c\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t4\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>nbsp2Space(str) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>var<\/code>&nbsp;<code>arrEntities = {<\/code><code>&#39;nbsp&#39;<\/code>&nbsp;<code>: <\/code><code>&#39; &#39;<\/code><code>};<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>str.replace(\/&amp;(nbsp);\/ig, <\/code><code>function<\/code><code>(all, t){<\/code><code>return<\/code>&nbsp;<code>arrEntities[t]})<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/\u56de\u8f66\u8f6c\u4e3abr\u6807\u7b7e\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>return2Br(str) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>str.replace(\/\\r?\\n\/g,<\/code><code>&quot;&lt;br \/&gt;&quot;<\/code><code>);<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/\u53bb\u9664\u5f00\u5934\u7ed3\u5c3e\u6362\u884c,\u5e76\u5c06\u8fde\u7eed3\u6b21\u4ee5\u4e0a\u6362\u884c\u8f6c\u6362\u62102\u6b21\u6362\u884c\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t4\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t5\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t6\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>trimBr(str) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>str=str.replace(\/((\\s|&amp;nbsp;)*\\r?\\n){<\/code><code>3<\/code><code>,}\/g,<\/code><code>&quot;\\r\\n\\r\\n&quot;<\/code><code>);<\/code><code>\/\/\u9650\u5236\u6700\u591a2\u6b21\u6362\u884c<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>str=str.replace(\/^((\\s|&amp;nbsp;)*\\r?\\n)+\/g,<\/code><code>&#39;&#39;<\/code><code>);<\/code><code>\/\/\u6e05\u9664\u5f00\u5934\u6362\u884c<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>str=str.replace(\/((\\s|&amp;nbsp;)*\\r?\\n)+$\/g,<\/code><code>&#39;&#39;<\/code><code>);<\/code><code>\/\/\u6e05\u9664\u7ed3\u5c3e\u6362\u884c<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>str;<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\n\t\/\/ \u5c06\u591a\u4e2a\u8fde\u7eed\u7a7a\u683c\u5408\u5e76\u6210\u4e00\u4e2a\u7a7a\u683c\n<\/p>\n<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td>\n<p>\n\t\t\t\t\t1\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t2\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t3\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t4\n\t\t\t\t<\/p>\n<\/td>\n<td>\n<p>\n\t\t\t\t\t<code>function<\/code>&nbsp;<code>mergeSpace(str) {<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>str=str.replace(\/(\\s|&amp;nbsp;)+\/g,<\/code><code>&#39; &#39;<\/code><code>);<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>&nbsp;<\/code><code>return<\/code>&nbsp;<code>str;<\/code>\n\t\t\t\t<\/p>\n<p>\n\t\t\t\t\t<code>}<\/code>\n\t\t\t\t<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>JS\u8f6c\u6362HTML\u8f6c\u4e49\u7b26 \/\/\u53bb\u6389html\u6807\u7b7e 1 2 3 function&nbsp;removeHtmlTab(tab) { &nbsp;return&#038;nbs&#8230; <\/p>\n<div class='button-mores'><a href='http:\/\/www.iooe.cn\/index.php\/2019\/09\/03\/js%e8%bd%ac%e6%8d%a2html%e8%bd%ac%e4%b9%89%e7%ac%a6-%e8%bf%99%e4%b8%aa%e6%af%94%e8%be%83%e5%a5%bd%e7%94%a8\/'> \u9605\u8bfb\u66f4\u591a&#8230; <\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[2],"tags":[],"_links":{"self":[{"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1361"}],"collection":[{"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/comments?post=1361"}],"version-history":[{"count":1,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1361\/revisions"}],"predecessor-version":[{"id":1362,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/posts\/1361\/revisions\/1362"}],"wp:attachment":[{"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/media?parent=1361"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/categories?post=1361"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.iooe.cn\/index.php\/wp-json\/wp\/v2\/tags?post=1361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}