Input Search autofocusProperty
Example
Check whether the search field automatically gets focus after the page loads:
var x = document.getElementById("mySearch").autofocus;
xThe output result is:true
Try it Yourself »
Definition and Usage
The autofocus property is used to set or return whether the search field automatically gets focus after the page loads.
This property reflects the HTML autofocus attribute.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the autofocus attribute
Note:Internet Explorer 9 and earlier IE versions, or Opera 12 and earlier Opera versions, do not support the autofocus attribute.
Syntax
Return the autofocus property:
searchObject.autofocus
Set the autofocus property:
searchObject.autofocus=true|false
Property Values
| Value | Description |
|---|---|
| true|false | Describes whether the search field gets focus after the page loads
|
Technical Details
| Return Value: | A Boolean value, returns true if the search field automatically gets focus after the page loads, otherwise returns false. |
|---|
Related Pages
HTML Reference Manual:HTML <input> autofocus Attribute
Input Search Object Other Extensions