<head>
  <script src="jquery.js"></script>
  <script>
    $(document).bind('autofocus_ready', function() {
      if (!("autofocus" in document.createElement("input"))) {
        $("#q").focus();
      }
    }
  </script>
</head>
<body>
  <form name="f">
  <input id="q" autofocus>
  <script>$(document).trigger('autofocus_ready');</script>
  <input type="submit" value="Go">
</form>
</body>

← back to Dive Into HTML5