Jeroen Swart

.NET Architect

IE6 focus problem

Today I had some trouble with setting the focus on an input element within an overlay panel in IE6. To be more specific: I had to set the focus on the lastname textbox in the search-argument panel for the people-search page in Sharepoint. Calling the focus() method worked in every opther browser except, of course, IE6.

The code that was causing the problem is as simple as this:


Apparently this is an ancient IE6 bug. Luckily the problem is easily fixed by using the setTimeout function. Just wrap the offending code like so:

setTimeout(function() { document.all['lastname'].focus() }, 0);
Comments are closed