Am just wondering if there is a way to give focus to a non-form element. I am asking because I am using the jhtmlArea plugin (http://jhtmlarea.codeplex.com/ - page currently down) in a project. And it does work, except that since it masks an IFRAME over a TEXTAREA the IFRAME, not being a form element, doesn't seem to want to receive focus. I think the demo on the official plugin page may have shown the IFRAME getting focus on load but I can't remember for sure and can't check now due to the plugin demo page not loading.
Asked
Active
Viewed 864 times
1
-
Try `attr('tabIndex', 0)` – elclanrs Jan 10 '13 at 00:58
-
http://jhtmlarea.codeplex.com/ - page back up now and their demo doesn't seem to show the IFRAME editor field automatically getting focus. – Christian Ziebarth Jan 10 '13 at 01:04
-
elclanrs, thanks. Tried your suggestion. It's not working right off the bat. Here's a jsfiddle that shows it: http://jsfiddle.net/7kTrB/6/ tabindex seems to only apply to form and A elements. – Christian Ziebarth Jan 10 '13 at 01:06
-
Curiously, the cursor does appear where you expect it to be once you click in the faux field and start typing. – Christian Ziebarth Jan 10 '13 at 01:12
1 Answers
0
Finally got it to work in my project but for some reason when I put the solution into the jsfiddle it only works in Chrome: http://jsfiddle.net/7kTrB/8/
The following line seems to be the most relevant part:
this.iframe[0].contentWindow.focus();

Christian Ziebarth
- 753
- 1
- 7
- 20