【问题标题】:How to focus a textfield using behavior-working in FF,but not in IE?如何在 FF 中使用行为工作而不是在 IE 中聚焦文本字段?
【发布时间】:2011-08-31 10:24:07
【问题描述】:

我试图将焦点放在当我单击特定链接时打开的弹出窗口中的文本字段上。我为此使用了检票口行为。但事实是它仅在 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();");
    }
}

【问题讨论】:

  • IE中是否有错误提示?
  • 你试过renderOnDomReadyJavascript而不是renderOnLoadJavascript吗?

标签: java javascript jakarta-ee wicket wicketstuff


【解决方案1】:

这是因为我在面板上尝试的事实。相反,如果它是在页面上完成的,它会起作用的。

【讨论】:

    猜你喜欢
    • 2011-12-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-15
    • 1970-01-01
    • 2014-05-07
    • 2010-12-20
    • 1970-01-01
    相关资源
    最近更新 更多