如何在 FF 中使用行为工作来聚焦文本字段,而不是在 IE 中?
我试图将焦点放在弹出窗口中的文本字段上,当我单击特定链接时,该窗口会打开。我为此使用了 wicket 行为。但事实是它仅在 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();");
}
}
I tried to put focus on a textfield in a pop-up window which opens up when i click on a particular link.I used wicket behavior for this.But the fact is it is working only in FF and not in IE.I am at my wit's end.Please help. My code is:
in .java file:
username.add(new FocusOnLoadBehavior());//username is the textfield and it is in a form.
The 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();");
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
发生这种情况是因为我正在尝试面板。相反,如果它是在页面上完成的,它就会起作用。
This occured due to the fact that i was trying on a panel. Instead if it was done on a page,it would have worked.