JavaScript HTML character encoding


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



Copy this code and paste it in your HTML
  1. function HTMLEncode(str){
  2. var result = '';
  3. for(var i=0; i<str.length; i++){
  4. result += '&#' + str.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.