当前位置: 代码迷 >> JavaScript >> 有没有方法给html进行编码?解决方法
  详细解决方案

有没有方法给html进行编码?解决方法

热度:39   发布时间:2012-03-06 20:47:55.0
有没有方法给html进行编码?
例如把 " < "、 "> "等字符编码成&lt、&gt这种格式?

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