Focus() not rowking on IE

Hi all,

This is more a javascript question, but hope someone can help me here.
I have the following code to show a login form using AJAX:

page.replace_html “login-form”,(render :partial =>
“login/login_top_form”)
page.replace_html “login_top_form_link”, link_to_hide_top_login_form

page.visual_effect(:appear,“login-form”)

page.delay(1) do
page[“user_email”].focus()
end

The code works well in FF and Opera, the field user_email gets the focus
but in IE I get an error:
“Can’t move focus to the control because is invisible, not enable, or of
a type that does not accept the focus”

I could get a solution to verify if the page[“user_email”] can get the
focus and ignore that behavior on IE, but I don’t know how.

Another question: can I get the type of browser inside an RJS template?

unfortunatly many people still use IE :frowning:

J. mp wrote:

Hi all,

This is more a javascript question, but hope someone can help me here.
I have the following code to show a login form using AJAX:

page.replace_html “login-form”,(render :partial =>
“login/login_top_form”)
page.replace_html “login_top_form_link”, link_to_hide_top_login_form

page.visual_effect(:appear,“login-form”)

page.delay(1) do
page[“user_email”].focus()
end

The code works well in FF and Opera, the field user_email gets the focus
but in IE I get an error:
“Can’t move focus to the control because is invisible, not enable, or of
a type that does not accept the focus”

I could get a solution to verify if the page[“user_email”] can get the
focus and ignore that behavior on IE, but I don’t know how.

Another question: can I get the type of browser inside an RJS template?

unfortunatly many people still use IE :frowning:

Forget it. I’m really dumb :slight_smile: I found out the problem.
I was putting javascript code at the end of the partial rtml code to get
the focus on the element :frowning:

Thanks