jsp页面初始化光标定位问题
我需要将页面初始化光标要定位在队列配置ID文本框,但是现在报错,
错误代码:由于该控件不可见、未启用、或其类型不允许,因此无法将焦点移向它。
源代码如下:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html>
<html:base/>
<head>
<title>队列管理器配置</title>
<link href="../skin_default/style_default_e.css" rel="stylesheet" type="text/css">
</head>
<body>
<html:form action="/qmQuery.do">
<bean:define id="pageURL" type="String" name="qmForm" property="pageURL"/>
<bean:define id="row" type="Integer" name="qmForm" property="rowCount"/>
<html:hidden name="qmForm" property="taskId"/>
<html:hidden name="qmForm" property="mqidone"/>
<html:hidden name="qmForm" property="pageLines" value="20"/>
<table width="100%" border="0" cellpadding="0" cellspacing="1" class="Search_box">
<tr>
<td class="Search_bg" id="searcharea"><TABLE border=0 align="left" cellPadding=0 cellSpacing=6 class="Search">
<TR>
<TD nowrap class="Search_item">队列管理器ID:</TD>
<TD nowrap class="Search_content"><html:text property="mqid" name="qmForm" styleClass="Search_input" tabindex="1" onkeydown="nextFocus(this.form)" /></TD>
<TD nowrap class="Search_item">名称:</TD>
<TD nowrap class="Search_content"><html:text property="mqname" name="qmForm" styleClass="Search_input" tabindex="2" onkeydown="nextFocus(this.form)" /></TD>
</TR>
<TR>
<TD nowrap class="Search_item">连接串:</TD>
<TD colspan="3" nowrap class="Search_content"><html:text property="mqurl" name="qmForm" styleClass="Search_input" size="50" tabindex="3" onkeydown="nextFocus(this.form)" onkeypress="stop(this.form)" />
</TD>
</TR>
<TD colspan="4" class="Search_button_bg">
<input type="button" value="查 询" class="Search_button" onclick="queryPage(this.form)" tabindex="4">
<input type="button" value="重 置" class="Search_button" onclick="resetText(this.form)"></TD>
</td></table>
<tr>
</table>
<script language="JavaScript" type="text/javascript">
<!--
document.forms["qmForm"].elements["mqid"].focus()
//-->
</script>
</html:form>
</body>
</html:html>
我还是过不用下面那段js,而是<html:form action="/qmQuery.do" focus="mqid">但是出现同样的错误。请如果知道原因了,请给点提示。
问题点数:20、回复次数:10Top
1 楼easyrun(深藏Blue)回复于 2005-08-26 16:00:21 得分 0
等Top
2 楼samplerain(samplerain)回复于 2005-08-26 16:40:19 得分 9
在html:form外面写写看
直接document.all.myid.focus()就行了
try~Top
3 楼easyrun(深藏Blue)回复于 2005-08-26 18:23:21 得分 0
还是不可以,这个方法我最早的时候用过的,提示找不到document.all.myid这个对象.
这个问题困扰我很久了,这个功能是可有可无.但是这个问题不能解决到我自己心里不痛快
!Top
4 楼samplerain(samplerain)回复于 2005-08-26 19:45:18 得分 1
把html:base去掉Top
5 楼easyrun(深藏Blue)回复于 2005-08-29 09:39:50 得分 0
html:base是不可以去了,使用了这个标签,该页面引用同一个应用其他页面时,只需要给出相对于当前网页的相对URL即可。这个标签一去整个页面的东西都乱了.Top
6 楼easyrun(深藏Blue)回复于 2005-08-31 12:31:47 得分 0
真的没人找的到合适的办法吗,如果下午5点还没有我就结帖了!Top
7 楼zeq258(周二强)回复于 2005-08-31 12:39:53 得分 5
要将光标定位,
很简单呀,
<html:text ......onfocus="true" />
在需要定位的标签设置onfocus就可以了!Top
8 楼easyrun(深藏Blue)回复于 2005-08-31 12:53:48 得分 0
这个方法也是用过的,在body那也试过onload,在form那也试过focus,都是不可以的!就是因为这些常规的方法都不行我才会来问得!Top
9 楼emersonwu()回复于 2005-08-31 15:45:51 得分 5
<script language="JavaScript" type="text/JavaScript">
<!--
function init() {
document.forms["qmForm"].elements["mqid"].focus()
}
//-->
<body onLoad="javascript:init()" >Top
10 楼easyrun(深藏Blue)回复于 2005-08-31 16:48:45 得分 0
谢谢大家,虽然问题没有解决!楼上的也不可以Top




