[英]escape special characters from html
我正在創建一個 html 表。
<table class=" table table-striped table-bordered table-hover">
<thead>
<tr>
<th>Remarks</th>
</tr></thead>
<tr>
<td> hello <hi> html </td>
</table>
當我運行上面的代碼時,我得到一個類似“hello html”的結果。 我需要顯示全文,如" hello <hi> html "
使用html 實體:
<td>hello <hi> html</td>
由於您標記了“Java”,我建議您使用Commons Text
庫將 html 字符轉換為實體。
你可以像這樣定義一個script
:
<script>
function loadPage() {
document.body.querySelector("td").innerText = unescape(escape(document.body.querySelector("td").innerHTML));
}
</script>
並添加
onload="loadPage();"
到body
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.