HTML special characters
- & (ampersand) becomes &
- " (double quote) becomes " when ENT_NOQUOTES is not set.
- ' (single quote) becomes '' only when ENT_QUOTES is set.
- < (less than) becomes <
- > (greater than) becomes >
- # (hash) becomes #
Javascript function to convert HTML special characters
function converHtml(s) {
var e = document.createElement("div");
e.innerText = e.textContent = s;
return e.innerHTML.replace(/"/g, """).replace(/#/,'#').replace(/'/,''');
}
No comments:
Post a Comment