Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Javascript in IE vs Firefox 1

Status
Not open for further replies.

RicksAtWork

Programmer
Nov 1, 2005
120
GB
Using event listners, I have attached a blur event to a set of text fields.

So, when I move out of any of these text boxes the blur event fires.

This calls a function called Checkvalues()

This checks the value of the current control.

If the controls data is incorrect, I want to reset the focus to this control.

I am doing this with the following code:

var errorMessage = CheckTaskValue(control);

if(errorMessage!=null)
{
alert(errorMessage);
control.focus();

}
In IE, this works fine, however in Firefox, it doesnt refocus.

What am I doing wrong?
 
This has been answered many times here. To save you doing a search, I'll give you the quick answer: Put the focus call in a setTimeout call with a really small delay (say, 50 msecs).

Hope this helps,
Dan





[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top