function HtmlEncode(text) { return text.replace(/&/g, ‘&‘).replace(/\"/g, ‘"‘).replace(/</g, ‘<‘).replace(/>/g, ‘>‘) }
还原:
function HtmlDecode(text) { return text.replace(/&/g, ‘&‘).replace(/"/g, ‘\"‘).replace(/</g, ‘<‘).replace(/>/g, ‘>‘) }
原文:http://www.cnblogs.com/shaoing/p/5358130.html