Site Navigation

Thursday, November 13, 2008

bug 505 - you can't programatically focus a link in IE unless another link has the focus

Issue: #505
Affects: IE6, IE7, IE8

Here's the scenario: You want to put the current focus on a hyperlink on the page, complete with that dotted border that indicates to the user, that the link has the focus.

Easy enough, right?


<script type="text/javascript">
var firstLink = document.getElementsByTagName('a')[0];

Well, try it out. In fact, just drop it in the location bar of any other browser as a bookmarklet to verify that it works.


Try the same thing in IE, and you'll notice that the dotted border doesn't show up! Press Tab, and you'll move focus to the next filed, press Shift Tab, and you'll move back, complete with the dotted border. The link does have the focus though... press Enter and you will activate the link.

To see how it should work, press Tab to move between the links on the page. Once you are on a link, complete with the visible dotted border focus, now call .focus() on any other link. Thus it only works in IE, if another link already has the focus, and it was achieved manually.

Known Workarounds: None.

Related Issues: None.

Bug/Site Feedback |
Submit a bug