On loading the page, you need to position the cursor on a specific field and automatically open the keyboard without touching the text field

How can I open the keyboard prompt without touching the textbox on page load? I also need to set the cursor to this field so that the keyboard will automatically open for easy input.

My code:



This will only work in Firefox browser, not chrome and others. Also in iphone the cursor is not set in this field.


source to share

1 answer

Note that we have an attribute autofocus

in HTML5 that does this without any javascript code.

For example:

<input type="text" name="fname" autofocus/>


You can refer to an example of autofocus



All Articles