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

Keygen autofocus property

Keygen autofocus property

Keygen Object Reference Keygen Object

Example

Check whether the keygen field automatically gets focus when the page loads:

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

x The output result is:

true

Try it »


Definition and usage

The autofocus property sets or returns whether the keygen field automatically gets focus when the page loads.

This property is the HTML autofocus attribute.


Browser support

Internet Explorer Firefox Opera Google Chrome Safari

All major browsers support the autofocus property, except Internet Explorer.

Note: The HTML autofocus attribute in the element is not supported by Firefox.


Syntax

Return the autofocus property:

keygenObject

.autofocus

Set the autofocus property:

keygenObject

.autofocus=true|false

Attribute values

Value Description
true|false Describes whether the keygen field gets focus when the page loads.
  • true - the keygen field gets focus
  • false - default. The keygen field does not get focus
  • |

    Technical description

    Return value: Boolean value, returns true if the keygen field automatically gets focus when the page loads, otherwise returns false

    Related pages

    HTML Reference Manual: HTML autofocus attribute


    Keygen Object Reference Keygen Object