HTMLEncode extend prototype


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. String.prototype.HTMLEncode = function (){
  2. var result = '';
  3. for(var i=0; i<this.length; i++){
  4. result += '&#' + this.charCodeAt(i) + ';';
  5. }
  6. return result;
  7.  
  8. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.