Set the autofocus
attribute in the control. Please note that this requires a browser that supports this particular bit of the HTML 5 project.
<textarea rows="4" cols="30" autofocus></textarea>
You can also set it using JavaScript, but it can interfere with the normal use of the page (especially with screen readers that use the focus point for reading) (there may also be an autofocus attribute, but it is at least standard so the software for reading with screen can be written for its work).
JavaScript method that I do not recommend:
<textarea rows="4" cols="30" id="mytextarea"></textarea> <script> document.getElementById('mytextarea').focus(); </script>
Note that this one does not use the onload event. This event does not fire until the entire document is loaded, including dependencies, such as images, so there is usually a significant delay with which the user can start interacting with the page. Adjusting the focus after this point is likely to disrupt the fact that the user is in the middle.
source share