Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM Input URL autofocus Property

Input URL autofocus property

Input URL Object Reference The Input URL object

Example

Check whether the URL field automatically gets focus after the page loads:

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

x

The output is:

true

Try it »


Definition and Usage

The autofocus property is used to set or return whether the URL field automatically gets focus after the page loads.

This attribute reflects the HTML autofocus attribute.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the autofocus property

Note: Internet Explorer 9 and earlier versions, or Opera 12 and earlier versions, do not support the autofocus property.

Note: Internet Explorer or Safari browsers do not support HTML that uses the type="url" attribute. .


Syntax

Return the autofocus attribute:

urlObject

.autofocus

Set the autofocus attribute:

urlObject

.autofocus=true|false

Attribute values

Value Description
true|false Describes whether the URL field gets focus after the page loads
  • true - The URL field gets focus
  • false - Default. The URL field does not get focus
  • |

    Technical Details

    Return Value: Boolean, returns true if the URL field automatically gets focus after the page loads, otherwise returns false.

    Related pages

    HTML Reference Manual: HTML autofocus attribute


    Input URL Object Reference The Input URL object