JavaScript: Bug using .focus() for legacy coding and FF

Hopefully you have found this article before you bashed your head open with your keyboard; if not, please seek medical help before continuing.

When using the .focus() method today, I came across an issue with Firefox — though, I would assume it is for all legitimate browsers. If you are having trouble getting .focus() working, kindly apply the following code.

setTimeout( function(){document.getElementById('field').focus();}, 10 );

Unfortunately, I have no reason why it works, I merely know that it does work.

Nick

Leave a Reply