xiaxueducun 2011-08-10 14:16
浏览 596
已采纳

【jsp+tomacat】chrome内核浏览器 报错 cannot call method 'getElementById' of undefined

我要实现多选项卡登录,选择不同选项卡,填写密码、用户名后,点击登录到不同的地方。
功能在IE内核的浏览器好用,在chrome内核浏览器时报错如下:
1、点击选项卡时报错:cannot call method 'getElementById' of undefined。
2、输入密码登录时,页面只刷新,不转跳。

代码如下:


<br> function qhdt1(a)<br> {</p> <pre><code>for(var i=1;i&lt;5;i++) { this.document.getElementById(&quot;dltp&quot;+i).src=&quot;&lt;%=request.getContextPath()%&gt;/image/dl-04-&quot;+i+&quot;-1.gif&quot;; } this.document.getElementById(&quot;lb&quot;).value=a; this.document.getElementById(&quot;dltp&quot;+a).src=&quot;&lt;%=request.getContextPath()%&gt;/image/dl-04-&quot;+a+&quot;-2.gif&quot;; hello.querylogin(a,test3); </code></pre> <p>}</p> <p>function test3(data)<br> {<br> //alert();<br> this.document.getElementById(&quot;logindiv&quot;).innerHTML=data;<br> //alert(document.getElementById(&quot;logindiv&quot;).innerHTML);<br> }</p> <p>function tj()<br> {</p> <pre><code>var lb=this.document.getElementById(&quot;lb&quot;).value; alert(lb); var yhm=this.document.getElementById(&quot;yhm&quot;); if(ChkUtil.isNull(yhm.value)) { alert(&quot;登录名称不能为空&quot;); yhm.focus(); return; } var mm=this.document.getElementById(&quot;mm&quot;); if(ChkUtil.isNull(mm.value)) { alert(&quot;密码不能为空&quot;); mm.focus(); return; } if(lb==1) { this.document.thisform.password.value = mm.value ; alert(mm.value); this.document.thisform.user.value = yhm.value ; alert(yhm.value); this.document.thisform.action=&quot;http://mail.hljbsm.gov.cn/?q=login.do&quot;; this.document.thisform.submit(); this.window.location.href=&quot;qt_index.jsp&quot;; }....... </code></pre> <p>}<br>

用户名: 密 码:

  • 写回答

3条回答 默认 最新

  • suziwen 2011-08-11 10:54
    关注

    [code="java"]document.thisform.action="http://mail.hljbsm.gov.cn/?q=login.do";
    document.thisform.submit();
    window.location.href="qt_index.jsp"; [/code]

    这个有问题,
    window.location.href="qt_index.jsp";
    这个已经是在document.thisform.submit()之后了,你又在同一个页面上
    所以qt_index.jsp永远也到不了

    提交时直接
    document.thisform.action= "qt_index.jsp";

    或者

    [code="java"]
    document.thisform.target="_aaa";
    document.thisform.action="http://mail.hljbsm.gov.cn/?q=login.do";
    document.thisform.submit();
    window._aaa.close();
    window.location.href="qt_index.jsp";[/code]
    看行不行

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 cgictest.cgi文件无法访问
  • ¥20 删除和修改功能无法调用
  • ¥15 kafka topic 所有分副本数修改
  • ¥15 小程序中fit格式等运动数据文件怎样实现可视化?(包含心率信息))
  • ¥15 如何利用mmdetection3d中的get_flops.py文件计算fcos3d方法的flops?
  • ¥40 串口调试助手打开串口后,keil5的代码就停止了
  • ¥15 电脑最近经常蓝屏,求大家看看哪的问题
  • ¥60 高价有偿求java辅导。工程量较大,价格你定,联系确定辅导后将采纳你的答案。希望能给出完整详细代码,并能解释回答我关于代码的疑问疑问,代码要求如下,联系我会发文档
  • ¥50 C++五子棋AI程序编写
  • ¥30 求安卓设备利用一个typeC接口,同时实现向pc一边投屏一边上传数据的解决方案。