YouTip LogoYouTip

Prop Search Autofocus

# Input Search autofocus Property [![Image 8: Input Search Object Reference](#) Input Search Object](#) ## Example Check if the search field automatically gets focus after the page loads: var x = document.getElementById("mySearch").autofocus; The output of _x_ is: true [Try it yourself Β»](#) * * * ## Definition and Usage The autofocus property sets or returns whether a search field should automatically get focus when the page loads. This property reflects the HTML autofocus attribute. * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) The autofocus property is supported in all major browsers. **Note:** The autofocus property is not supported in Internet Explorer 9 and earlier IE versions or Opera 12 and earlier Opera versions. * * * ## Syntax Return the autofocus property: _searchObject_.autofocus Set the autofocus property: _searchObject_.autofocus=true|false ## Property Values | Value | Description | | --- | --- | | true|false | Specifies whether the search field gets focus when the page loads * true - The search field gets focus * false - Default. The search field does not get focus | ## Technical Details | Return Value: | A Boolean. Returns true if the search field automatically gets focus after the page loads, otherwise false. | | --- | * * * ## Related Pages HTML Reference: (#) * * Input Search Object](#)
← Prop Search AutofocusDom Obj Search β†’