JS 将 HTML 编码实体中的 href 更改为 onclick
JS Change hrefs to onclicks in HTML encoded entities
我正在遍历一个数据库,该数据库的字符串包含 HTML 个实体:
"<!-- SC_OFF --><div class=\"md\"><p>这是一个<a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\">example link</a></p>\n\n<p>Here is some body text for you with <sup>superscript</sup> and a bit of <strong>boldness</strong> and some <em>italics</em>. I forgot to mention this regular link here <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\"><a href="http://example.com</a>" rel="nofollow">http://example.com</a></a>; so don't forget that one. sometimes there can be more than one <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\">formatted link</a> and <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\"><a href="http://example.com</a></p>" rel="nofollow">http://example.com</a></p></a>;\n\n<ul>\n<li>到此为止</li>\n<li>一些示例文本可以使用</li>\n</ ul>\n\n<p><del>删除线</del></p>\n\n<pre><code>if(canCode){\n //lol don't kid yourself\n }\n
\n
我正在遍历一个数据库,该数据库的字符串包含 HTML 个实体:
"<!-- SC_OFF --><div class=\"md\"><p>这是一个<a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\">example link</a></p>\n\n<p>Here is some body text for you with <sup>superscript</sup> and a bit of <strong>boldness</strong> and some <em>italics</em>. I forgot to mention this regular link here <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\"><a href="http://example.com</a>" rel="nofollow">http://example.com</a></a>; so don't forget that one. sometimes there can be more than one <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\">formatted link</a> and <a href=\"<a href="http://example.com" rel="nofollow">http://example.com</a>\"><a href="http://example.com</a></p>" rel="nofollow">http://example.com</a></p></a>;\n\n<ul>\n<li>到此为止</li>\n<li>一些示例文本可以使用</li>\n</ ul>\n\n<p><del>删除线</del></p>\n\n<pre><code>if(canCode){\n //lol don't kid yourself\n }\n
\n