Javascript String escapeHTML()
String.prototype.escapeHTML = function() { return this./*from w w w. j a va2 s .c o m*/ replace(/&/g, "&"). replace(/</g, "<"). replace(/>/g, ">"). replace(/\"/g, """); }; console.log("<&>".escapeHTML()); // -> "<&>"
String.prototype.escapeHTML = function() { var m = {"&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/'}; return String(this).replace(/[&<>"'\/]/g, function(s) {/*from www. j av a 2 s .c o m*/ return m[s]; }); }
String.prototype.escapeHTML = function(){ var str = this.replace(/</g, '<'); return str.replace(/>/g, '>'); };
String.prototype.escapeHtml = function() { return this.replace(/&/g, "&").replace(/</g, "<").replace(/\"/g, """); };
var entityMap = { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''', '/': '/' }; String.prototype.escapeHtml = function() { return this.replace(/[&<>"'\/]/g, function (s) { return entityMap[s]; });/*from ww w. j a v a 2s.c o m*/ }; function getCookie(name) { var cookieStr = document.cookie; var cookieList = cookieStr.split('; '); for (var i = 0; i < cookieList.length; i++) { var cookie = cookieList[i].split('='); if (cookie[0] == name) { return decodeURI(cookie[1]); } } return ''; }
String.prototype.escapeHTML = function () { return(this.replace(/&/g,'&').replace(/>/g,'>').replace(/</g,'<').replace(/"/g,'"')); };
var __entityMap = { "&": "&", "<": "<", ">": ">", '"': '"', "'": ''', "/": '/' }; String.prototype.escapeHTML = function() { return String(this).replace(/[&<>"'\/]/g, function(s) { return __entityMap[s]; });/*from w w w . ja va2 s . c om*/ }