Topic: ItWhy would this work in firefox but not IE?

I'm trying to get the cursor to focus in a certain text_field.  This works fine in firefox 3 beta, but it isn't working in IE 7.0.  But I have it working in another app on both, but there I used the content_for("script"), while here I'm trying to use a helper.

# in my view (this code is within a form)
Username: <%= text_field 'user', 'username', :size => 20 %>
<%= focus("user_username") %>

# the focus(...) helper
def focus(field_name)
    js = "<script type='text/javascript'>"
    js << "$(#{field_name}).focus();"
    js << "</script>"
  end

Re: ItWhy would this work in firefox but not IE?

My suggestion is moving the script all the way to the bottom of the page. IE has issues with working on the DOM while it is still rendering it.