At LUNARMEDIA I found this function below will take a string and return a HTML-encoded version of it!
function escapeHTML (str)
{
var div = document.createElement('div');
var text = document.createTextNode(str);
div.appendChild(text);
return div.innerHTML;
};
Wednesday, October 3, 2007
A simple effective HTML-escape/encode function in Javascript!
By
Sten Hougaard
on
Wednesday, October 03, 2007
Etiketter: Javascript, utility
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment