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 www. j a v a 2s .c o m document.getElementById("myText").focus(); }; </script> </body> </html>