我要实现多选项卡登录,选择不同选项卡,填写密码、用户名后,点击登录到不同的地方。
功能在IE内核的浏览器好用,在chrome内核浏览器时报错如下:
1、点击选项卡时报错:cannot call method 'getElementById' of undefined。
2、输入密码登录时,页面只刷新,不转跳。
代码如下:
<br> function qhdt1(a)<br> {</p> <pre><code>for(var i=1;i<5;i++) { this.document.getElementById("dltp"+i).src="<%=request.getContextPath()%>/image/dl-04-"+i+"-1.gif"; } this.document.getElementById("lb").value=a; this.document.getElementById("dltp"+a).src="<%=request.getContextPath()%>/image/dl-04-"+a+"-2.gif"; hello.querylogin(a,test3); </code></pre> <p>}</p> <p>function test3(data)<br> {<br> //alert();<br> this.document.getElementById("logindiv").innerHTML=data;<br> //alert(document.getElementById("logindiv").innerHTML);<br> }</p> <p>function tj()<br> {</p> <pre><code>var lb=this.document.getElementById("lb").value; alert(lb); var yhm=this.document.getElementById("yhm"); if(ChkUtil.isNull(yhm.value)) { alert("登录名称不能为空"); yhm.focus(); return; } var mm=this.document.getElementById("mm"); if(ChkUtil.isNull(mm.value)) { alert("密码不能为空"); 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="http://mail.hljbsm.gov.cn/?q=login.do"; this.document.thisform.submit(); this.window.location.href="qt_index.jsp"; }....... </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]