List of utility methods to do HTML Escape
escapeHTML()String.prototype.escapeHTML = function() { return this. replace(/&/g, "&"). replace(/</g, "<"). replace(/>/g, ">"). replace(/\"/g, """); }; console.log("<&>".escapeHTML()); | |
escapeHTML()String.prototype.escapeHTML = function(){ var str = this.replace(/</g, '<'); return str.replace(/>/g, '>'); }; | |
escapeHTML()String.prototype.escapeHTML = function() var m = {"&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/'}; return String(this).replace(/[&<>"'\/]/g, function(s) return m[s]; }); | |
escapeHTML()String.prototype.escapeHTML = function () { return(this.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"')); }; | |
escapeHTML()var __entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; String.prototype.escapeHTML = function() { ... | |
escapeHTML()String.prototype.escapeHTML = function() { return this.replace(/</g,'<').replace(/>/g, '>'); }; | |
escapeHTML()String.prototype.escapeHTML = function() { return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); }; | |
escapeHTML()var __entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; String.prototype.escapeHTML = function() { ... | |
escapeHTML()String.prototype.escapeHTML = function () { return ('' + this).replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"'); }; | |
escapeHtml()String.prototype.escapeHtml = function() { return this .replace(/&/g, '&') .replace(/"/g, '"') .replace(/'/g, ''') .replace(/</g, '<') .replace(/>/g, '>'); }; |