Javascript String htmlspecialchars()

Description

Javascript String htmlspecialchars()


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



PreviousNext

Related