11 September 2008 ~ 0 Comments

It’s Not As Helpful As You’d Think

Web sites frequently make use of JavaScript’s onLoad event handler in conjunction with focus() to reposition the cursor once the page has finished loading.  Here’s a page full of search results on javascript focus.

Pages do this so that you can begin typing immediately without having to first TAB or click-focus on an obvious starting point: the “Wireless number” field in the AT&T login screen for example:

Take a quick look back at the screencap.  You’ll notice the characters “yz” in the “Wireless number” field.  That’s not my wireless number.  It’s the last two letters of my password.  I certainly didn’t start by typing my password given my familiarity with the login/password paradigm, so how did it happen?

When I’m halfway through my password, the onLoad event is fired and this helpful JavaScript kicks in, relocating my cursor and blanking out the fields. Even though most sites aren’t as aggressive in removing your previous values, they refocus nonetheless. In those cases, I would be left with “yz55555555555″ which is still a problem.

Here’s a quick suggestion: In the onLoad event handler, if focus has moved on to another field or if another field has fired key related events, don’t refocus.

Get to work AT&T! :-)

Leave a Reply