Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

html form field focus in Firefox

Posted on 2011-10-16
7
Medium Priority
?
150 Views
Last Modified: 2012-05-12
<form>
<input name="username" id="username_id">
</form>

 <script type="text/javascript">
document.getElementById("username_id").focus();
</script>

why can't I set the field focus in FF
it works in chrome / ie
0
Comment
Question by:joomla
  • 3
  • 3
7 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 36977261
work for me : http://jsfiddle.net/mZb7w/
window.onload = function() { document.getElementById("username_id").focus(); }

Open in new window

0
 

Author Comment

by:joomla
ID: 36977271
Hi leakim971

this script is part of a php page
i can't use the onload function
i had thought by placing the call after the form it would work

seems to work in ie & chrome, not ff
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 36977272
Works on all my forms.  Do you have more than one instance of id="username_id" ?  You can press Ctl-Shft-J to see the Error Console in Firefox to see if it thinks there is an error.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 83

Expert Comment

by:leakim971
ID: 36977310
>i can't use the onload function

why?
0
 

Author Comment

by:joomla
ID: 36977406
I'm sorry for taking both your time.
Based on both your insistence that the code should work, I took more time reviewing it.
It appears it does in fact work, however in Chrome the select() hightlights any text in the focused field.

I hadn't realised the cursor was actually in place in the field when using FF, just not highlighting the existing text.

is this correct?
If so, can I split the points for you both ?
thanks
0
 
LVL 83

Accepted Solution

by:
leakim971 earned 200 total points
ID: 36977411
>I hadn't realised the cursor was actually in place in the field when using FF, just not highlighting the existing text.
>is this correct?

yes
0
 

Author Closing Comment

by:joomla
ID: 36977458
thanks for help
sorry for making it harder than it needed to be
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

580 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question