当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Why doesn't html:form struts tag trigger focus event?

问题描述:

The following html code:

<html:form action="myAction" focus="code">

<html:text styleId="inputCode" property="code" />

</html>

generates the following javascript code:

<script type="text/javascript" language="JavaScript">

<!--

var focusControl = document.forms["MyForm"].elements["code"];

if (focusControl != null && focusControl.type != "hidden"

&& !focusControl.disabled && focusControl.style.display != "none") {

focusControl.focus();

}

// -->

</script>

which should focus the code input text, but it isn't. I have tried writting that exactly same javascript code in my ready function and that way it works perfectly. Does anyone have any idea what is going on?

分享给朋友:
您可能感兴趣的文章:
随机阅读: