函数里的参数带有单引号怎么办,穿出去的值有问题,而且参数不能修改,因为是文件名,请看下面代码
<A href=\"javascript:openpic('"+pdfpath+"')\" >clickhere</A>
function openpic(picpath){
   picpath=escape(picpath);
//从这里传出去的picpath就是空值了
   window.open("customershowpic.jsp?path="+picpath);}

解决方案 »

  1.   

      是不是  picpath=escape(picpath);
         var picpath=escape(picpath);
      

  2.   

     
    <A id="aa" >clickhere</A>
     
       $("#aa").click(function(){
            var picpath=escape(picpath);        window.open("customershowpic.jsp?path="+picpath);
       });
      

  3.   

    你的语法好像有问题(如果是html中的话)
    <A href=\"javascript:openpic('"+pdfpath+"')\" >clickhere</A>
    +号在js中工作
    如果这个A标签是在html中的话,我没有什么方法。
    用js去生成的话倒是可以,或者你直接把'换成%27好了。<A href="javascript:openpic('%27picpath')" >clickhere</A><html>
    <script>
    function dosomething(){
    var d = document.getElementById("123");
    var abc = "a'b";
    d.innerHTML = "<a href=\"" + escape(abc) + "\">domlink</a>";
    }
    </script>
    <body onload="dosomething()">
    <div id="123"></div>
    </body>
    </html>
      

  4.   

    window.open("customershowpic.jsp?path="+picpath+"");