Take the 2-minute tour ×
Webmasters Stack Exchange is a question and answer site for pro webmasters. It's 100% free, no registration required.
<INPUT TYPE=TEXT NAME="Gw" MAXLENGTH="225" size="42" autofocus="autofocus">

If I try this with Google Chrome it works. I just want to highlight a form without <script>.

Why doesn't it work?

share|improve this question
    
What version of Firefox are you using? –  John Conde Jun 9 '11 at 13:26
    
Which Version are you using of Firefox ? In Past firefox did not support autofocus but it is fine and working at my side.... I am using firefox 4. –  user17031 Jul 16 '12 at 23:04
add comment

2 Answers 2

up vote 2 down vote accepted

It should work in Firefox 4. But if you're using an older version of Firefox it won't work as the autofocus attribute is new to HTML5 which only gained broad support in Firefox 4..

share|improve this answer
add comment

It's wise to use autofocus with a JavaScript fallback for browsers that don't support it. From Mark Pilgrim's Dive into HTML5 Forms:

What’s that? You say you want your autofocus fields to work in all browsers, not just these fancy-pants HTML5 browsers? You can keep your current autofocus script. Just make two small changes:

  1. Add the autofocus attribute to your HTML markup
  2. Detect whether the browser supports the autofocus attribute, and only run your own autofocus script if the browser doesn’t support autofocus natively.
<form name="f">
  <input id="q" type="text" name="Gw" maxlength="225" size="42" autofocus>
  <script>
    if (!("autofocus" in document.createElement("input"))) {
      document.getElementById("q").focus();
    }
  </script>
  <input type="submit" value="Go">
</form>

Live demo here.

share|improve this answer
    
It's a bad thing I could accept two answers, yours would be the 2 :( :) Thank you! –  LanceBaynes Jun 9 '11 at 15:03
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.