Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should focus be given to a control when a webpage finishes loading?

Tags:

usability

Here are some examples of what I mean:

google.com - focus is set on the "search" box

gmail.google.com - focus is set on the "user name" field (actually, most web email clients do this).

stackoverflow, ask a question - focus is set on the "title" box.

Sometimes, this is a convenient feature - e.g., on Google. From a usability standpoint, however, is it really considered a good feature to have on login pages?

Personally, I have often entered my user name, started to enter my password, then the page finished loading and had focus put back onto the user name field. Unfortunately, since I have complex passwords that force me to look at the keyboard while typing, I fail to notice when focus shifts. I often wind up typing my password in the unmasked user name field for anyone standing behind me to see.

Another situation, less dangerous but still annoying, is when I'm typing a url in my address bar while my homepage is still loading. As soon as it finishes, however, and if I'm not done entering the url, focus is stolen from me and put on some other field.

Should websites and/or browsers be programmed so that focus won't change if the user is already interacting with the site or the browser? Do problems like this bother ordinary (i.e., non-programmer) users?

like image 314
Cybis Avatar asked Mar 30 '09 05:03

Cybis


3 Answers

These are really two separate questions with different answers:

Q: Should focus be given to the input field the user is most likely to use?

A: Most definitely yes, if "most users" really is 90% or more.

Q: Should this happen when the webpage finishes loading?

A: No. The "onLoad" event is a pretty stupid place to put this. The input field should get the focus as soon as it appears - it's usually completely irrelevant when the page finishes loading. Just put a <script> tag that sets the focus right after the input element itself.

like image 93
Michael Borgwardt Avatar answered Nov 08 '22 22:11

Michael Borgwardt


I personally hate it when websites assume the focus. The main reason is that on my laptop, if I'm using the track pad and hit the backspace key it will automatically navigate back to the previous page. If focus has been placed on a textbox it will treat the backspace as tho I'm trying to delete a character.

My personal preference (and this has very little to do with best practice) is that it nothing should have initial focus, but the first tab will take it to the element that you want to have initial focus.

like image 36
lomaxx Avatar answered Nov 08 '22 22:11

lomaxx


The same happened to me in Gmail, I find it slightly annoying, especially since it should be easy to circumvent: In the OnLoad event handler, check if the input boxes (username or password) already contain text. If this is the case, do not change the focus.

As with all simple solutions, I would not be surprised if there were some strange side effects that render it unpractical, but I would give it a try anyway. Oh, and if it works, why don't you send an email to Google? ;-)

That being said, I consider this behaviour a usability glitch, something that is not a bug, but slightly annoying. Don't annoy your customers. Fix it.

like image 2
Treb Avatar answered Nov 08 '22 23:11

Treb