日期:2014-05-16  浏览次数:20430 次

有没有方法给html进行编码?
例如把 " < "、 "> "等字符编码成&lt、&gt这种格式?

------解决方案--------------------
String.prototype.replaceStr=function(){return this.replace(/&/g, "&amp; ").replace(/\ "/g, "&quot; ").replace(/ </g, "&lt; ").replace(/> /g, "&gt; ");}