<form action="tool.html" method = "get">
      查找您想要的应用
      <input name="searchFor" type="text" size="10" />
      <input name="goButton" type="submit" value="搜索" />
    </form>我把这个get的值传到这个静态页面, 但是中文都是乱码 论坛上的大神说用decodeURIComponent这个方法进行解码。 不过我用了IE说是无效字符, 请求大神帮助。 别的方法也可以
var qs = window.location.search.substring(1);
var ar = qs.split('&');
var tmp = ar[0].split('=');
var str = decodeURI(tmp[1]);

解决方案 »

  1.   

    //IE下执行下面这样代码会报错?不可能吧!
    alert(decodeURIComponent('%E6%B5%8B%E8%AF%95'));
      

  2.   

    就是编码的那个html文档的编码么? 怎么保证编码一致啊?
      

  3.   

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 文件也改为utf-8  
      

  4.   

    这行代码确实可以, 是不是因为我用的是GB2312的编码所以不行啊? 需要都改成UTF-8么?
      

  5.   

    是的。你可以试一下。如果是gbk编码,你需要把经 encodeURIComponent() 编码后的值传递过去。那边才可以decodeURIComponent 解码。