//转义
function htmlEncode(s) {
if (s.length == 0)return "";
s = s.replace(/&/g, "&");//必须在第一个位置
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/'/g, "'");
s = s.replace(/"/g, """);
return s;
}
//反转义
function htmlDecode(s) {
if (s.length == 0)return "";
s = s.replace(/</g, "<");
s = s.replace(/>/g, ">");
s = s.replace(/'/g, "'");
s = s.replace(/"/g, '"');
s = s.replace(/&/g, "&");//最好放在最后一个
return s;
}