/ Published in: JavaScript
Expand |
Embed | Plain Text
String.prototype.htmlEntities = function () { return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }; //Usage 1: var tmp = '<html><head></head>'; var safe= tmp.htmlEntities(); // Returns "<html><head></head>"
You need to login to post a comment.
