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?

9
  • what code do you are trying ? Commented Aug 9, 2017 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, it would seem that the focus method is indeed part of DOM Level 1. Commented Aug 9, 2017 at 20:49
  • 1
    element.focus() was around prior to 2006 for sure. Commented Aug 9, 2017 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 Commented Aug 9, 2017 at 20:52
  • 1
    I read that too and it surprised me. Commented Aug 9, 2017 at 21:00

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

i was just wondering if the focus method was available in JS 1.7. apparently it is :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.