3300.me

escape_html

last update: 2016/12/12
function escapeHTML(str) {
  if(!str){return '';}
  return str.replace(/["'`<>&]/g, function(m) {
    return {
      '"': '&quot;',
      "'": '&#x27;',
      '`': '&#x60;',
      '<': '&lt;',
      '>': '&gt;',
      '&': '&amp;',
    }[m]
  });
}

code_popup