HTML在线转义

将普通的未转义 HTML 代码转换为转义的 HTML,反之亦然。

转义和编码 HTML 有什么区别?


转义是编码的一个子集。转义时,并非所有字符都进行编码。只有 & 符号、小于 符号和大于符号在 HTML 转义中编码。&<>

何时转义 HTML?


如果要在网页中显示实际代码而不由浏览器执行或处理所述代码,请转义 HTML。请参阅下面的示例。

源代码(转义两次)结果
&lt;textarea&gt;Hello, world!&lt;/textarea&gt;
<textarea>Hello, world!</textarea>
'),childWindow.document.write(document.getElementById("input_output").value.replace(/\n/gi,"
")),childWindow.document.write(""),childWindow.print(),childWindow.document.close(),childWindow.close()}1==examples&&area.val(`HTML tag example

and

HTML entities: & (ampersand) < (less than) > (greather than) `),$("#escapeHtmlBtn").click(function(){Remember();var e=escapeHtml(area.val());area.val(e),Remember()}),$("#unescapeHtmlBtn").click(function(){Remember();var e=unescapeHtml(area.val());area.val(e),Remember()}),$(".clipboard").click(function(){Clipboard(area)}),$("#clearAll, #edit_delete, #file_new").click(function(){area.val(""),Remember()}),$("#file_upload").on("change",function(){loadText()}),$("#file_download").click(function(){saveText()}),$("#file_print").click(function(){printTextArea()}),$("#edit_undo").click(function(){var e=History.undo();void 0!==e&&area.val(e)}),$("#edit_redo").click(function(){var e=History.redo();void 0!==e&&area.val(e)}),$("#edit_copy").click(function(){Clipboard(area)}),$("#edit_select").click(function(){area.select().focus()});var History=function(){var t=[],n=0;return{remember:function(e){t[n-1]!==e&&(t.splice(n,10),t.push(e),t.splice(0,t.length-10),n=t.length)},undo:function(){if(1