开发者

How to focus a textfield using behavior-working in FF,but not in IE?

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 开发者_如何学Gostatic 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();");
    }
}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜