HTML | DOM Input image autofocus Property
The HTML DOM input Image autofocus Property is used to set or return whether the Input Image Field should get focus or not when the page loading. It reflects the HTML autofocus attribute.
Syntax:
- It returns the autofocus property.
imageObject.autofocus
- It is used to set the autofocus property.
imageObject.autofocus = "true|false"
Property values:
- true: It sets the focus of Input Image.
- false: It is the default value. It defines the Input Image field does not get focus.
Return value: It returns the boolean value which represents the image field gets autofocus or not.
Example 1: This example sets the Input Image autofocus property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Image autofocus Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h4> DOM Input Image autofocus Property </h4> <input id="myImage" formEnctype="application/x-www-form-urlencoded" type="image" formtarget="#" src= alt="Submit" width="48" height="48" formMethod="post" autofocus> <br> <br> <button onclick="my_geek()">Submit </button> <h2 id="Geek_h" style="color:green;"> </h2> <script> function my_geek() { // set Disabled Property. var txt = document.getElementById( "myImage").autofocus; document.getElementById( "Geek_h").innerHTML = txt; } </script> </body> </html> |
Output:
- Before Clicking On Button:

- After Clicking On Button:

Example 2: This example returns the Input Image autofocus property.
<!DOCTYPE html> <html> <head> <title> HTML DOM Input Image autofocus Property </title> </head> <body style="text-align:center;"> <h1 style="color:green;"> GeeksforGeeks </h1> <h4>DOM Input Image autofocus Property</h4> <input id="myImage" formEnctype="application/x-www-form-urlencoded" type="image" formtarget="#" src= alt="Submit" width="48" height="48" formMethod="post" autofocus> <br> <br> <button onclick="my_geek()">Submit </button> <h2 id="Geek_h" style="color:green;"> </h2> <script> function my_geek() { // set Disabled Property. var txt = document.getElementById( "myImage").autofocus = false; document.getElementById( "Geek_h").innerHTML = txt; } </script> </body> </html> |
Output:
- Before Clicking On Button:
- After Clicking On Button:

Supported Browsers: The browsers supported by HTML DOM Input image autofocus Property are listed below:
- Googl Chrome 10.0
- Firefox 4.0
- Opera 11.0
- Safari 5.1
Recommended Posts:
- HTML | DOM Input URL autofocus Property
- HTML | DOM Input Reset autofocus Property
- HTML | DOM Input Time autofocus Property
- HTML | DOM Input Range autofocus Property
- HTML | DOM Input Color autofocus Property
- HTML | DOM Input FileUpload autofocus Property
- HTML | DOM Input Date autofocus Property
- HTML | DOM Input Radio autofocus Property
- HTML | DOM Input Week autofocus Property
- HTML | DOM Input Datetime autofocus Property
- HTML | DOM Input Number autofocus Property
- HTML | DOM Input Submit autofocus Property
- HTML | DOM Input Text autofocus Property
- HTML | DOM Input Month autofocus Property
- HTML | DOM Input Button autofocus Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



