0

I am trying to figure out if there is a way to auto-focus an input element on page load that is compatible with HTML 4.01 Strict, CSS 2.1, and JS 1.7, since the autofocus attribute is not available to HTML 4.01 and I do not believe the focus method is available in JS 1.7.

Is there a way to still accomplish this with those restrictions?

I think I may have found an answer to my question. According to this w3.org document, the focus method belongs to the DOM Level 1. Does this mean that the method is indeed available?

oldboy
  • 5,729
  • 6
  • 38
  • 86
  • what code do you are trying ? – Jesus Carrasco Aug 09 '17 at 20:48
  • @JesusCarrasco i'm coding a website according the PS4 browser specifications. i think i may have found an answer to my question, nonetheless. according to [this document](https://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#method-focus), it would seem that the `focus` method is indeed part of DOM Level 1. – oldboy Aug 09 '17 at 20:49
  • 1
    element.focus() was around prior to 2006 for sure. – James Aug 09 '17 at 20:49
  • @James yeah, i edited my question. i came across a w3.org document that says it belongs to DOM Level 1. i wasn't sure because i couldn't find anything about it until a few seconds ago – oldboy Aug 09 '17 at 20:52
  • if you find the answer yourself try to post for other poeople may have the same question. – Jesus Carrasco Aug 09 '17 at 20:56
  • @JesusCarrasco just modify your answer and explain that it is available. leave the code but maybe add some links to documentation. perhaps it will help somebody in the future – oldboy Aug 09 '17 at 20:56
  • @James one more quick question. i had read that `let` was around back then, but was it same as `let` nowadays? and was `const` also around back then? – oldboy Aug 09 '17 at 20:58
  • 1
    I read that too and it surprised me. – James Aug 09 '17 at 21:00
  • @James surprising eh lol – oldboy Aug 09 '17 at 21:01

1 Answers1

1

According to this w3.org document, the focus method belongs to the DOM Level 1 so is available.

Try this code is javascript vanilla.

JAVASCRIPT

window.onload = function() {
   document.getElementById("Box1").focus();
};

HTML

<input type="text" id="Box1"/>

Anthony who was the person was asking confirm from his research. thx. Anthony Hope this help other people.

Jesus Carrasco
  • 1,355
  • 1
  • 11
  • 15