Input Email autofocus attribute
Definition and usage
autofocus
Property setting or returning whether the email 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 email field automatically gains focus when the page is loaded:
var x = document.getElementById("myEmail").autofocus;
Syntax
Return autofocus attribute:
emailObject.autofocus
Set autofocus attribute:
emailObject.autofocus = "true|false"
Attribute value
Value | Description |
---|---|
true|false |
Specifies whether the email field should gain focus when the page is loaded.
|
Technical details
Return value: | Boolean value, returned if the email field automatically gains focus when the page is loaded true ;otherwise return false 。 |
---|
Browser support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |
All major browsers support autofocus
Properties.
Note:Internet Explorer 9 and earlier versions or Opera 12 and earlier versions do not support autofocus
Properties.
Note:Internet Explorer 9 and earlier versions or Safari do not support the <input type="email"> element.