Focus on the correct place

There are some good ways to use JavaScript on the web site to make the life of the user easier. The reputation of JavaScript has gone bad due to the abuse of it.

One of these ways is to use focus() when there is some input field(s) on the page. Usually on a login page or anywhere similar where users are expected to fill in some data.

<body onload="document.login.user.focus();">

In the code above it is assumed that you have a form named “login” in the page, and within the form a field called “user”.