StringUtils.js
715 Bytes
var __string_utils = {
//处理HTML 属性值中的单引号
fixSingleQuote: function(value){
var _temp_val = value;
if(value){
var tag_sign = "'";
if(value.indexOf(tag_sign)>=0){// contains '
_temp_val = value.replace(new RegExp(tag_sign,"g"),"'")
}
}
return _temp_val;
},
escapeHtml : function (string) {
var entityMap = {
"&": "&",
"<": "<",
">": ">",
'"': '"',
"'": ''',
"\\": '\',
"/": '/'
};
return String(string).replace(/[&<>\"\'\/]/g, function (s) {
return entityMap[s];
});
}
}