是用js的escape方法 但是有个问题:
  %、#、+、&这四个字符并不能都会编码 其次escape方法后还要用unescape方法解码 这样是不是有点不合适呢????

解决方案 »

  1.   

    如果自己定义一个函数 是否比较好,还是有点得不尝试呢 欢迎大家提点意见function swapParameter(swapData)
    {
    if (swapData == null)
    return null;

    while(swapData.indexOf("%") != -1)
    swapData = swapData.replace("%", "%25");

    while(swapData.indexOf("#") != -1)
    swapData = swapData.replace("#", "%23");

    while(swapData.indexOf("+") != -1)
    swapData = swapData.replace("+", "%2B");

    while(swapData.indexOf("&") != -1)
    swapData = swapData.replace("&", "%26");

    return swapData;
    }不需要解码同时实现编码的功能 可以吗
      

  2.   

    encodeURIComponent
    encodeURIComponent 方法
    将文本字符串编码为一个统一资源标识符 (URI) 的一个有效组件。encodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。
    decodeURIComponent
    decodeURIComponent 方法
    返回统一资源标识符 (URI) 的一个已编码组件的非编码形式。decodeURIComponent(encodedURIString)必选的 encodedURIString 参数代表一个已编码的 URI 组件。
    <script language=javascript>
    var strs="fasodfasklfj&*^%^#)*(@^(&*#(@(#$&+"
    strs=encodeURIComponent(strs)
    document.write(strs)
    document.write("<br>")
    document.write(decodeURIComponent(strs))
    </script>
      

  3.   

    只要是url,好像是用escape函数后,都不用解码,得到的就是正确的数据
      

  4.   

    以前我的参数中有汉字时,用escape就好使