我试图将焦点放在弹出窗口中的文本字段上,当我单击特定链接时会打开该窗口。我为此使用了检票口行为。但事实是它仅在 FF 中有效,而在 IE 中无效。我在我的智慧结束了。请帮忙。我的代码是:在 .java 文件中:
username.add(new FocusOnLoadBehavior());//username is the textfield and it is in a form.
FocusOnLoadBehavior:
public class FocusOnLoadBehavior extends AbstractBehavior {
private static final long serialVersionUID = 1L;
private Component component;
public void bind(Component component) {
this.component = component;
component.setOutputMarkupId(true);
}
public void renderHead(IHeaderResponse iHeaderResponse) {
super.renderHead(iHeaderResponse);
iHeaderResponse.renderOnLoadJavascript("document.getElementById('"
+ component.getMarkupId() + "').focus();");
}
}