function HtmlEncode(text) { return text.replace(/&/g, '&').replace(/\"/g, '"').replace(/</g, '<').replace(/>/g, '>')}
来源: http://www.phpxs.com/code/1003794/