IE6 focus problem

by Jeroen 12 January 2010 18:20

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:

document.all['lastname'].focus();

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);

Tags: , , ,

Theme by Codeblack

About me

I'm a .NET Architect with Quintor in Groningen, The Netherlands. I work with .NET, C#, SQL Server, etcetera. I'm also involved in ALM using Visual Studio and Team Foundation Server.

History

Pages