Give focus to a text field, immediately after the document window has been loaded:
In this example, the text field gets focus immediately after the document window has been loaded.
<!DOCTYPE html> <html> <body> <input type="text" id="myText" value="A text field"> <script> window.onload = function() {/*from w w w. j a v a 2 s. c om*/ document.getElementById("myText").focus(); }; </script> </body> </html>