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

问题描述

我要实现多选项卡登录,选择不同选项卡,填写密码、用户名后,点击登录到不同的地方。功能在IE内核的浏览器好用,在chrome内核浏览器时报错如下:1、点击选项卡时报错:cannot call method 'getElementById' of undefined。2、输入密码登录时,页面只刷新,不转跳。代码如下:<head><script type="text/javascript">function qhdt1(a){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);}function test3(data){//alert();this.document.getElementById("logindiv").innerHTML=data;//alert(document.getElementById("logindiv").innerHTML);}function tj(){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";}.......}</script ><body><table width="970" border="0" align="center" cellpadding="0" cellspacing="0"> <tr> <td width="525"><table width="525" border="0" align="left" cellpadding="0" cellspacing="0"> <tr> <td colspan="2"><table width="525" border="0" cellspacing="0" cellpadding="0"> <tr> <td><a onclick="qhdt1(1)"><img src="<%=request.getContextPath()%>/image/dl-04-1-2.gif" width="116" height="24" border="0" id="dltp1" /></a></td> <td><a onclick="qhdt1(3)"><img src="<%=request.getContextPath()%>/image/dl-04-3-1.gif" width="116" height="24" border="0" id="dltp3" /></a></td> <td><a onclick="qhdt1(4)"><img src="<%=request.getContextPath()%>/image/dl-04-4-1.gif" width="155" height="24" border="0" id="dltp4" /></a></td> <td><a onclick="qhdt1(2)"><img src="<%=request.getContextPath()%>/image/dl-04-2-1.gif" width="138" height="24" border="0" id="dltp2" /></a></td> </tr> </table></td> </tr> <tr> <td width="6"><img src="<%=request.getContextPath()%>/image/dl-02.gif" width="6" height="36" /></td> <td width="519" background="<%=request.getContextPath()%>/image/dl-01.gif"><table width="510" border="0" align="left" cellpadding="0" cellspacing="0"> <form method=post action="" name="thisform" target="_blank"><!--tr> <td width="102"><img src="<%=request.getContextPath()%>/image/dl-biao.gif" width="102" height="27" /></td> <td width="70" align="right" class="text-12-hui" style="padding-top:3px;">用户名:</td> <td width="82"><label> <input name="yhm" id="yhm" type="text" size="10" /> </label></td> <td width="54" align="right" class="text-12-hui" style="padding-top:3px;">密 码:</td> <td width="92"><input name="mm" id="mm" type="Password" size="10" /></td> <td width="59"><a href="javascript:tj()"><img src="<%=request.getContextPath()%>/image/dl-an-1.gif" width="48" height="21" border=0/></a></td> <!--td width="51"><img src="<%=request.getContextPath()%>/image/dl-an-2.gif" width="48" height="21" /></td--> </tr--> <tr> <td><div id="logindiv"><table><tr> <td width="102"><img src="<%=request.getContextPath()%>/image/dl-biao.gif" width="102" height="27" /></td> <td width="70" align="right" class="text-12-hui" style="padding-top:3px;">用户名:</td> <td width="82"><label> <input name="yhm" id="yhm" type="text" size="10" /> </label></td> <td width="54" align="right" class="text-12-hui" style="padding-top:3px;">密 码:</td> <td width="92"><input name="mm" id="mm" type="Password" size="10" style="height:15px;" /></td> <td width="59"><a href="javascript:tj()"><img src="<%=request.getContextPath()%>/image/dl-an-1.gif" width="48" height="21" border=0/></a></td> <!--td width="51"><img src="<%=request.getContextPath()%>/image/dl-an-2.gif" width="48" height="21" /></td--> </tr> </table></body> 问题补充:cloverprince 写道

解决方案

document.thisform.action="http://mail.hljbsm.gov.cn/?q=login.do"; document.thisform.submit(); window.location.href="qt_index.jsp"; 这个有问题,window.location.href="qt_index.jsp";这个已经是在document.thisform.submit()之后了,你又在同一个页面上所以qt_index.jsp永远也到不了提交时直接document.thisform.action= "qt_index.jsp";或者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";看行不行
解决方案二:
楼主对this的理解还不是很到位~~~~http://www.jb51.net/article/19425.htm
解决方案三:
不要this,直接document.getElementById。

时间: 2024-08-02 23:00:40

【jsp+tomacat】chrome内核浏览器 报错 cannot call method &#039;getElementById&#039; of undefined的相关文章

tomcat-JAVA问题:初学Struts2框架遇到的浏览器报错

问题描述 JAVA问题:初学Struts2框架遇到的浏览器报错 现在是验证Struts2的参数接收,但是页面直接就显示不出来 一:JSP页面----------> 二:XML配置----------> 三:控制器类--------------> 四:TomCat没有报错,浏览器报404找不者 解决方案 你的页面用的action路径Can/user_save,而你的Action配置路径是C_method的名称,不匹配啊. 修正你的action的配置,统一一下呗. 解决方案二: 你的问题是s

asp 连接数据库-ASP网站不能在其他电脑上打开,浏览器报错为没有找到LocalDB实例名

问题描述 ASP网站不能在其他电脑上打开,浏览器报错为没有找到LocalDB实例名 这是我的数据库连接代码 <add name="DatabaseConnectionString2" connectionString="Data Source=(LocalDB)MSSQLLocalDB;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;Connect Timeout=30"

jsp 访问 java文 件报错

问题描述 jsp 访问 java文 件报错 访问java文件报错如下 访问的java文件如下 跪求 解决方案 空指针了,调试看看哪个对象是null 解决方案二: 空指针异常,你查看调用的对象!我猜应该是业务层,sql语句的拼写大小写 解决方案三: 看看你的rd 是不是空了. 解决方案四: 应该是rd为null,, 解决方案五: rd为空,估计是jsp路径有问题

在FF chrom中加载xml是可以的,但用到加载jsp中的xml 会报错

问题描述 在FF chrom中加载xml是可以的,但用到加载jsp中的xml 会报错 js加载的jsp文件 jsp文件内容 解决方案 你的page指令和include放一行去,并且<?xml申明紧跟include指令后面,要不你的xml格式会出错 xml申明前面不能有空白行 解决方案二: 报的错误,报错误的jsp页面头部

dynamic-我建立的是Dynamic Web Project ,然后就建立一个jsp文件,但是就报错404

问题描述 我建立的是Dynamic Web Project ,然后就建立一个jsp文件,但是就报错404 我建立的是Dynamic Web Project ,然后就建立一个jsp文件,什么都没有改变 运行就报404 求指教 解决方案 你项目发布到到哪儿去了,看看你发布上去了,访问路径也看看. 解决方案二: 访问路径写详细了它就好了 解决方案三: 路径问题 解决了

C# 开发Chrome内核浏览器(WebKit.net)

原文:C# 开发Chrome内核浏览器(WebKit.net)   WebKit.net是对WebKit的.Net封装,使用它.net程序可以非常方便的集成和使用webkit作为加载网页的容器.这里介绍一下怎么用它来显示一个网页这样的一个最简单的功能. 第一步: 下载WebKit.net 的bin文件.别小看这一步,你不一定能下载成功,原因你懂的. WebKit.net 的主页是http://webkitdotnet.sourceforge.net/ 直接下载0.5版本的windows bin文

操作系统-linux2.6内核编译报错

问题描述 linux2.6内核编译报错 做操作系统内核编译模块实验遇到的问题. Makefile ifneq ($(KERNELRELEASE),) # We were called by kbuild obj-m += clock.o else # We were called from command line KDIR := /lib/modules/$(shell uname -r)/build #KDIR := /home/cynove/src/kernel/linux-source-

javascript-下面是一个html和js实现的wheel移动到目的位置,但是浏览器报错,错误应该在指定行,

问题描述 下面是一个html和js实现的wheel移动到目的位置,但是浏览器报错,错误应该在指定行, <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus?"> <meta name="Author&

mozilla-xulrunner Java浏览器报错,谁可以帮忙看看吗

问题描述 xulrunner Java浏览器报错,谁可以帮忙看看吗 2015-11-18 18:13:54 org.mozilla.browser.MozillaInitialization initialize 信息: Using xul runner dir: D:lyscannativewin32xulrunner 2015-11-18 18:13:54 org.mozilla.browser.MozillaInitialization initialize 严重: failed to i