admin管理员组文章数量:1414621
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 ments.
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.
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 ments.
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.
1 Answer
Reset to default 4You could probably emulate the desired behavior (probably with less issues than detecting TAB key) by onfocus/onblur events of the relevant input elements. This way you don't CARE how the user got to the editor input, whether it'd be via TABs or clicking or some weird FireFox AddOn which allows you to jump to input element by its ID/name/# (I'm almost certain such add-on exists :)
UPDATE. OP clarified the problem in the ments.
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.
SOLUTION:
In the parent frame, create a new <INPUT>
element. It will be invisible (e.g. via CSS or making size 1x1), will have name/id of "Body_clone", and will have the TABINDEX attribute value which follows the TABINDEX of "Subject" field. It will also have an onFocus handler which will simply find the "Body" input element inside the IFRAME and call focus()
on that element.
You can do the same with tabbing/shift-tabbing out of IFRAME "Body" element by creating "Subject_iframe_clone" and "After-body_iframe_clone" input elements in the IFRAME which work just like "Body_clone" did.
本文标签:
版权声明:本文标题:jquery - Is there a JavaScript event that fires when a tab index switch is triggered? (TABINDEX does not work for inputs in IFRA 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745189981a2646866.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论