两个静态页a.html和b.html
我想把a.html文本框的值get到b.html页面中去. 
但值是非中文的就可以,中文的就会出现乱码.<form id="form_youbian" action="/b.html" target="_blank" method="get" >
<input type="hidden" name="txt" id="hide_youbian" value="" />
<input type="submit" style="width:100px" value="查询" id="btnSubmit_youbian"/></p></div>
</form>
// 这样传过去就是乱码 而且我用js通过encodeURIComponent转码 然后在b.html解码也不好用大家谁有经验说下.谢谢

解决方案 »

  1.   


    我的两个页面是UTF-8编码
      

  2.   

    b.html 你是如何接收参数的?
      

  3.   

    a: 端encodeURI(url+“中文”);
    b:端decodeURI(url);
      

  4.   

    A 页面是UTF-8的话, 用 FORM ,GET 方式提交,没有问题
    a.htm
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <form method="get" action="b.htm">
    <input name="ps" value="我是ps0" />
    <input name="ps" value="我是ps1" />
    <input name="ps" value="我是ps2" />
    <input name="param" value="文字!@#&*)(#$?." />
    <input type="submit" />
    <input type="button" value="JS 提交" onclick="jsSubmit(this.form)" />
    </form>
    <script type="text/javascript">
    function jsSubmit(frm) {
    var params = [];
    var inputs = frm.getElementsByTagName("input");
    for (var i=0; i<inputs.length; i++) {
    var input = inputs[i];
    if (input.type=='text') params.push(encodeURIComponent(input.name) + "=" + encodeURIComponent(input.value));
    }
    location = "b.htm?" + params.join("&");
    }
    </script>
    b.htm
    <script type="text/javascript">
    RegExp.escape = function(str) { return String(str).replace(/([.*+?^=!:${}()|[\]\/\\])/g, '\\$1'); };
    function getParameterValues(name) {
    var pattern = RegExp.escape(encodeURIComponent(name));
    var regex   = new RegExp("(?:^|\\?|&)"+pattern+"=([^&]*)", "g");
    var values = [];
    location.search.replace(regex, function() { values.push(decodeURIComponent(arguments[1])) });
    return values;
    }
    function getParameter(name) {
    return getParameterValues(name).join(", ");
    }
    var ps = getParameterValues("ps");
    alert(ps[0]);
    alert(ps[1]);
    alert(ps[2]);var param = getParameter("param");
    alert(param);
    </script>