HTML文字處理


我們如何運作的:

function htmlEscape(text) {
  /*警告不得二次處理字串*/
  return String(text)
    .replaceAll("&", "&")
    .replaceAll("<", "&lt;")
    .replaceAll(">", "&gt;")
    .replaceAll('"', "&quot;")
    .replaceAll("'", "&#39;")
    .replaceAll(/\t/g, content.value)
    .replaceAll("\n", "<br>\n")
    .replaceAll(" ", "&nbsp;")
    ;
}