简体   繁体   English

使用jsp和struts 1自动聚焦于html标签

[英]autofocus on html tag using jsp and struts 1

I work with jsp and Struts 1. I need to set up the focus on login button in this page on load in order to make login faster. 我使用jsp和Struts1。我需要在加载时在此页面上将焦点设置在登录按钮上,以加快登录速度。

This is my html form: 这是我的html形式:

<html:form action="/someAction.do" method="post"> 
  <tr><td class="someClass" align=right>email: </td><td><html:text size="40" property="email"/><td></td></tr>
  <tr><td class="someClass" align=right>password: </td><td><html:password size="40" property="password"/><td></td></tr>
  <tr><td align=center colspan=2><br/>
    <html:submit value="login"/>
 </td></tr>

I've tried to do this: 我试图做到这一点:

<html:submit value="login" property="submit"/>

and then use javascript: 然后使用javascript:

window.onload = function(){
document.getElementsByName("submit").focus();
}

And this is not working. 这是行不通的。

I wanted to use "Id" attribute for tag but I don't know how can I do this in the Struts 1. Does anyone know the Struts 1? 我想为标签使用“ Id”属性,但是我不知道如何在Struts 1中做到这一点。有人知道Struts 1吗? )) ))

You can use styleId . 您可以使用styleId For example - 例如 -

UserName: <html:text property="userName" styleId="userName"></html:text>
PassWord: <html:password property="passWord" styleId="passWord"></html:password>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM