1focusMethod = function getFocus() {
2 document.getElementById("myButton").focus();
3}
1window.onload=function(){
2 document.getElementById("id_here").focus();
3}
4// id_here = put the id of the HTML element where you want to set focus.
1<input type="text" id="myTextField" value="Text field.">
2<p></p>
3<button type="button" onclick="focusMethod()">Click me to focus on the text field!</button>
4