views:

37

answers:

1

I have jQuery which produces a popup window, as outlined here:

http://www.jsfiddle.net/sLjfx/4/

The problem is that the following line:

$('#txtValuation').focus();

doesn't seem to want to work in IE8. The popup will load, but the textbox doesn't have focus, where in Chrome the box does have focus.. Is there any work-around for it?

+1  A: 

I don't have IE8 handy, but try this: I fired up my Windows VM, and this works: http://www.jsfiddle.net/n25HE/ All I did was wrap the focus call in a function and call it 10ms after your event handler finished, like this:

setTimeout(function() {
    $('#txtValuation').focus();
}, 10);

This gives IE time to actually render the content and create the OS control for the text input. IE can't focus things before the underlying control exists.

T.J. Crowder