Is there a JavaScript event that fires when a tab index switch is triggered? (TABINDEX does not work for inputs in IFRAME)

Posted by treeface on Stack Overflow See other posts from Stack Overflow or by treeface
Published on 2011-01-04T01:12:40Z Indexed on 2011/01/04 3:54 UTC
Read the original article Hit count: 233

My specific use case is that I have a WYSIWYG editor which is basically an editable iframe. To the user, however, it looks like a standard-issue textarea. My problem is that I have inputs that sit before and after this editor in the (perceived) tab index and I'd like the user to be able to press tab (or the equivalent on his platform of choice) to get to the WYSIWYG editor when he's in the previous element and shift-tab to get to it when he's in the latter element.

I know this can be faked using the key events and checking whether or not the tab key was pressed, but I'm curious if there's a better way.


UPDATE. treeface clarified the actual problem in the comments.

PROBLEM:

In normal case, you can use "TABINDEX" attribute of the <input> element to control that, when tabbing out of "Subject" input field (in an email form), the focus lands on "Body" input field in the e-mail. This is done simply by assigning correctly ordered values to "TABINDEX" attribute of both input fields.

The problem is that TABINDEX attribute only orders elements within the same frame. So, if "Body" input field is actually in an internal IFRAME, you can't tab out of "Subject" in the parent frame straight into "Body" in the IFRAME using TABINDEX order.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery