/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
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>"