Input URL autofocus Attribute

Definition and Usage

autofocus Attribute to set or return whether the URL field should automatically gain focus when the page is loaded.

This property reflects the HTML autofocus attribute.

See Also:

HTML Reference Manual:HTML <input> autofocus Attribute

Example

Determine whether the URL field automatically gains focus when the page is loaded:

var x = document.getElementById("myURL").autofocus;

Try It Yourself

Syntax

Return the autofocus attribute:

urlObject.autofocus

Set the autofocus attribute:

urlObject.autofocus = true|false

Attribute Value

Value Description
true|false

Specify whether the URL field should gain focus when the page is loaded.

  • true - The URL field receives focus
  • false - Default. The URL field does not receive focus

Technical Details

Return Value: Boolean value, returned if the URL field automatically receives focus when the page is loaded true; otherwise return false.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Supported 10.0 Supported Not Supported Supported