文本框没有焦点 [英] Text box has no focus

查看:88
本文介绍了文本框没有焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个文本框,在我的表格上我无法关注。我正在使用它显示:

< head>

< body onload = document.getPassword.txtPasswordName.focus( )>

< / head>


其中

getPassword表格&

txtPasswordName是文本框


为什么会这样?有人知道更好的方法吗?

I have a text box, on my form that I cant get the focus on. I''m using it as
shown:
<head>
<body onload=document.getPassword.txtPasswordName.focus( )>
</head>

Where
getPassword is the form &
txtPasswordName is the text box

Why is this? Anyone know a better way of doing this?

推荐答案

" JCO" <Ĵ******** @ verizon.net>。在消息中写道

新闻:UV ***************** @nwrddc03.gnilink.net ...
" JCO" <J.********@verizon.net> wrote in message
news:UV*****************@nwrddc03.gnilink.net...
我有一个文本框,在我的表格上,我不能得到关注。我正在使用
,如下所示:
< head>
< body onload = document.getPassword.txtPasswordName.focus()>
< / head>

其中
getPassword是表格&
txtPasswordName是文本框

为什么会这样?有人知道更好的方法吗?
I have a text box, on my form that I cant get the focus on. I''m using it as shown:
<head>
<body onload=document.getPassword.txtPasswordName.focus( )>
</head>

Where
getPassword is the form &
txtPasswordName is the text box

Why is this? Anyone know a better way of doing this?



你可能不能使用onload ="因为表格没有加载。


删除" onload ="并在页面末尾添加以下内容:


< script type =" text / javascript">

document.getPassword.txtPasswordName。 focus();

< / script>


You probably can''t use "onload=" as the form isn''t loaded.

Remove "onload=" and add the following at the end of the page:

<script type="text/javascript">
document.getPassword.txtPasswordName.focus();
</script>


McKirahan写道:
McKirahan wrote:
" JCO" <Ĵ******** @ verizon.net>。在消息中写道
新闻:UV ***************** @nwrddc03.gnilink.net ...
" JCO" <J.********@verizon.net> wrote in message
news:UV*****************@nwrddc03.gnilink.net...
我有一个文本框,在我的表格上,我不能得到关注。我正在使用它
I have a text box, on my form that I cant get the focus on. I''m using it





as

显示:
< head>
< body onload = document.getPassword.txtPasswordName.focus()>
< / head>

其中
getPassword是表格&
txtPasswordName是文本框

这是为什么?有人知道更好的方法吗?
shown:
<head>
<body onload=document.getPassword.txtPasswordName.focus( )>
</head>

Where
getPassword is the form &
txtPasswordName is the text box

Why is this? Anyone know a better way of doing this?



你可能不能使用onload ="因为表单没有被加载。



You probably can''t use "onload=" as the form isn''t loaded.




因为onload事件只发生在文档加载之后(那就是它的b $ b $)然后表格确实已加载。

OP:

一个主要问题,可能/可能不是问题根源的一部分,

是body标签位于< / head>之后标签,身体不是部分

头部。虽然大多数浏览器都会错误地纠正汤码,并且当遇到body标签时,
会关闭头部。在

抱怨javascript之前验证HTML。


这还取决于getPassword是否是

的名称或ID形式(重要)。对于txtPasswordName也是一样的。


验证你的代码有效后,如果它仍然没有设置焦点,请发布最小代码(或URL)

到了违规的页面。


-

兰迪

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq/



Since onload events only happen after the document is loaded (thats what
its for), then the form is indeed loaded.
OP:
One major problem, and may/may not be part of the source of the problem,
is that the body tag goes after the </head> tag, the body is not part of
the head section. Although most browsers error correct soup code and
close the head when it encounters the body tag. Validate HTML before
complaining about javascript.

It also will depend on whether getPassword is the name or the id of the
form (It matters). Same for txtPasswordName.

Validate your code, after its valid, if it still doesn''t set focus, post
the minimum code (or a URL) to the offending page.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/


是表格名称是getPassword,文本框名称是txtPasswordName。

如图所示:


< FORM NAME =" getPassword" onSubmit =" return GetUserInput()">

< p align =" center">& nbsp;< INPUT TYPE =" password" NAME =" txtPasswordName"

VALUE ="" SIZE = 14>& nbsp;

< input type =" reset"值= QUOT;清零" name =" btnClear">< / p>

< p align =" center">输入密码< / p>


基于此表单,onload如下所示:

< body onload = document.getPassword.txtPasswordName.focus()>


此外,重要的是要注意,当我在浏览器中预览

时,焦点设置正确。网站发布后无效。


再次感谢您的投入!


" Randy Webb" <喜************ @ aol.com>在消息中写道

新闻:DY ******************** @ comcast.com ...
Yes the form name is getPassword and the text box name is txtPasswordName.
As shown:

<FORM NAME="getPassword" onSubmit="return GetUserInput()">
<p align="center">&nbsp;<INPUT TYPE="password" NAME="txtPasswordName"
VALUE="" SIZE=14>&nbsp;
<input type="reset" value="Clear" name="btnClear"></p>
<p align="center">Enter Password</p>

Base on this form, the onload is as shown:
<body onload=document.getPassword.txtPasswordName.focus( )>

Also, an important thing to note, the focus is set correctly when I preview
it in the browser. It does not work after the site is published.

Thanks again for the inputs!

"Randy Webb" <hi************@aol.com> wrote in message
news:DY********************@comcast.com...
McKirahan写道:
McKirahan wrote:
" JCO" <Ĵ******** @ verizon.net>。在消息中写道
新闻:UV ***************** @nwrddc03.gnilink.net ...
" JCO" <J.********@verizon.net> wrote in message
news:UV*****************@nwrddc03.gnilink.net...
我有一个文本框,在我的表格上,我不能得到关注。我正在使用
I have a text box, on my form that I cant get the focus on. I''m using



it
as

显示:
< head>
< body onload = document.getPassword.txtPasswordName.focus()>
< / head>

其中
getPassword是表格&
txtPasswordName是文本框

这是为什么?有人知道更好的方法吗?
shown:
<head>
<body onload=document.getPassword.txtPasswordName.focus( )>
</head>

Where
getPassword is the form &
txtPasswordName is the text box

Why is this? Anyone know a better way of doing this?



你可能不能使用onload ="因为表单没有被加载。



You probably can''t use "onload=" as the form isn''t loaded.



因为onload事件只发生在文档加载之后(这就是它的用途),然后确实加载了表单。 br />
OP:
一个主要问题,可能/可能不是问题根源的一部分,
是身体标签在< / head>之后。标签,身体不是头部的一部分。虽然大多数浏览器都会错误地纠正汤码并且在遇到身体标签时关闭头部。在
抱怨javascript之前验证HTML。

它还取决于getPassword是
表单的名称还是id(重要)。对于txtPasswordName也是如此。

验证代码有效后,如果代码仍未设置焦点,则将最小代码(或URL)发布到违规页面。 />
-
兰迪
机会有利于准备好的心灵
comp.lang.javascript常见问题 - http://jibbering.com/faq/



这篇关于文本框没有焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆