Javascript String htmlspecialchars()
String.prototype.htmlspecialchars = function(){ var s = this.replace(/&/g, '&'); s = s.replace(/'/g, "'"); s = s.replace(/"/g, '"'); s = s.replace(/</g, '<'); s = s.replace(/>/g, '>'); return s;//from www.j a va 2s . c o m };