提交表单和获取表单内容都是用javascript客户端脚本,请问怎么解决?

解决方案 »

  1.   

    HTM 可以处理表单吗?不明白。
      

  2.   

    是呀!
    页面如下:
    test1.htm
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <form action="test2.htm" method="get">
    <input name="test" type="text" value="测试">
    <input type="submit" name="Submit" value="提交">
    </form>
    </body>
    </html>页面test2.htm<html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
    <title>无标题文档</title>
    </head><body>
    <script language="javascript">
    function getQuery(name)
    {
        var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r!=null) return unescape(r[2]); return null;
    }
    alert(getQuery("test");
    </script>
    </body>
    </html>
      

  3.   

    我是用javascript客户端脚本处理表单的
      

  4.   

    把 unescape 换成 decodeURI 试试。
      

  5.   

    不过这个函数只有在 JS5.5 之后才有,如果考虑到兼容性,可以在表单发送之前使用 escape 对表单内容进行一下处理。