Focus onload

02.Aug.2010

It is useful to focus on input field after page is loaded when user is presented with login form. Once page is loaded we shall set focus on input field so user would not need to use mouse in order to focus on it.

1
2
3
4
5
6
7
8
<input type="text" id="my-onload-focus-input" />
 
<script>
function focus_onload() {
	document.getElementById('my-onload-focus-input').focus();
}
window.onload = focus_onload();
</script>