【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>

用户名:密 码:

[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]
看行不行

不要this,直接document.getElementById。

楼主对this的理解还不是很到位~~~~

[url]http://www.jb51.net/article/19425.htm[/url]