各位大侠:小弟请教一个简单的document.location.href的写法,
现在我在一个javascript的函数里面要用document.location.href,使得页面跳转到tcyw_cfm.jsp,同时在url的后面带上两个参数code,code1,我是这样写的:
document.location.href = '/service/operate/tcyw_cfm.jsp?code='+form.op_code.value+'&code1='+form.op_code1.value;当我只带一个参数code的时候页面可以跳转,加上code1后页面就不跳转了,哪里写错了?谢谢了!!
在线等

解决方案 »

  1.   

    请在location前alert form.op_code1.value
      

  2.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>test</title>
    </head>
    <script type="text/javascript">
    function test(){
    alert('/service/operate/tcyw_cfm.jsp?code= '+form.op_code.value+ '&code1= '+form.op_code1.value);
    }
    </script>
    <body>
    <form method="post" id="form">
    <input name="" type="text" id="op_code"/>
    <input name="" type="text" id="op_code1"/>
    <input name="" type="button" value="click" onclick="test()"/>
    </form>
    </body>
    </html>
      

  3.   

    代码如楼上,,
    如果拼出的路径过长,也会导致转向失败。
    IE里,href的最大长度是2K
      

  4.   

    "楼上的,按照四楼的写法页面也是不跳转的啊"
    -----------
    这问题感觉好像是没看就问的alert('/service/operate/tcyw_cfm.jsp?code= '+form.op_code.value+ '&code1= '+form.op_code1.value);
    --->>>
    location.href=
      

  5.   

    ..........我一直以为get方式的最大字符数是4K
      

  6.   

    楼主不妨看看代码里面其他地方有没有错误,如果有错误比如页面里面没有op_code1这个控件的话,页面也是不会跳转的