地址:http://localhost:12135/Hotel/HotelMappingView.aspx?city=深圳
获取js
[code=JScript]
function aa(source, name) {
        var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
        if (reg.test(source)) return RegExp.$2; return "";
    };
var city = aa(window.location.href, "city");
得到的参数是
%E6%B7%B1%E5%9C%B3
若何解码或者直接获取中文.?

解决方案 »

  1.   

    <script>
    document.write(decodeURI("%E6%B7%B1%E5%9C%B3"));
    </script>结果:深圳
      

  2.   

    alert(decodeURIComponent("%E6%B7%B1%E5%9C%B3"))
      

  3.   

    decodeURIComponent
    是这个方法。
      

  4.   

    这个没得说 必须是decodeURIComponent方法
      

  5.   

    utf-8 编码用
    decodeURIComponent() 或者 decodeURI 解码
      

  6.   

    用decodeURI()与decodeURIComponent()都可以,效果上基本没什么区别
    decodeURI() 函数可对 encodeURI() 函数编码过的URI 进行解码
    decodeURIComponent() 函数可对 encodeURIComponent() 函数编码的 URI 进行解码
      

  7.   

    encodeURI不编码字符有82个:!,#,$,&,',(,),*,+,,,-,.,/,:,;,=,?,@,_,~,0-9,a-z,A-Z
    encodeURIComponent不编码字符有71个:!, ',(,),*,-,.,_,~,0-9,a-z,A-Z
      

  8.   

    上面说的UTF-8,注意除了在HTML页面里指定,还要注意文件本身的编码,你可以用文本文档打开HTML文件,然后在另存为时看它底下的编码是什么,如果不是UTF-8,就改好再另存,我在没有做上面那些函数转化时,中文的参数也能正常得到,但最好还要做些转化好