如题 我想到用
<script language=javascript>
  function func_del(path) {
   document.form1.delpath.value = path.replace("\\", "\\\\");
   document.form1.act.value = "delete";
   document.form1.submit();
  }
</script><a href='javascript:func_del("<%=myfiles[i].getName()%>")'>删&nbsp;除</a>
如<%=myfiles[i].getName()%>只要时121\132,  44\3,等中间有“\”的删除时候就会出错我想到了用replace不过不行,replaceAll的javascript不支持,看看谁能有好的想法,或帮我调试一下上边代码,谢谢,小弟初学,在线等

解决方案 »

  1.   

    function kk()
    {
    var str = @"abc\ppabc";            //@path of your file
    var test = str.replace('\\','');   //@replace \
    alert(str);
    }
    这样试试
      

  2.   

    function replaceAll(strChk, strFind, strReplace) {
      var strOut = strChk;
      while (strOut.indexOf(strFind) > -1) {
        strOut = strOut.replace(strFind, strReplace);
      }
      return strOut;
    }
      

  3.   

    楼上  没看懂   要传递三个值strChk, strFind, strReplace 都应该是什么呢?
      

  4.   

    用split吧,在js中有这个方法,你找段代码看看吧
      

  5.   

    strChk:原始字符串  例如:“12\123”
    strFind:需要被替换的字符   “\”
    strReplace:用来替换的字符   ""