.focus() "set Focus On A Target Input" Will Not Work In Firefox
I have an input field. Under certain conditions I want to keep the user focused on the input field when they hit the Tab key. Basically I'm mimicking the functionality of Google's
Solution 1:
As you are using jQuery should use the .focusout() method.
http://api.jquery.com/focusout/
This is distinct from the blur event in that it supports detecting the loss of focus from parent elements (in other words, it supports event bubbling).
Solution 2:
I was able to resolve my situation by avoiding my question above.
Since I am dealing with the Tab key, instead of trying to place the focus back in the field that the user tabbed out of (like my attempt above), I used preventDefault() on the Tab key. Therefore focus is never lost, and I don't have to worry about replacing it.
displayTextBox.keydown
(
function(event)
{
// 9 = Tab Keyif (event.keyCode == "9")
{
event.preventDefault();
}
}
);
I have not thoroughly tested this, but it seems to work so far in FF, Chrome and IE.
Solution 3:
Try to use the html attribute onfocusout
Post a Comment for ".focus() "set Focus On A Target Input" Will Not Work In Firefox"