替换js双引号、斜杠

来源:互联网 发布:淘宝白银 编辑:程序博客网 时间:2024/06/11 11:15

 

String.prototype.replaceAll = function(str1,str2){
  var regS = new RegExp(str1,"gi");
  return this.replace(regS,str2);
}
/**
 * 将Html代码转换成可显示的代码
 * */
function showHtml(html){
  html = html.replaceAll("<","&lt;");
  html = html.replaceAll(">","&gt;");
  html = html.replaceAll("/"","&quot;");
  return html;
}

// 单选列对象
     var radioObj = {
      header : '选择',
      id : 'userinfo_id',
      width : 40,
      hidden : false,
      sortable : false,
      renderer : function(value, p, record) {
       return '<input type="radio" name="userinfo" value="'
         + showHtml(Ext.util.JSON.encode(record.data))
         + '" id="" onclick="returnWinOfValue(this.value)">';
      }
     };

 

// 设置参数返回到父窗体 返回二维数组
function returnWinOfValue(obj) {
    window.returnValue = obj;
 window.close();
}

原创粉丝点击