views:

962

answers:

5

hi, i have an ifram, which has hidden visibility. i click on button - iframe will be visible and i want to focus on its body/content. because now i must click on button and then into iframe, so thats two clicks. i want to do it on one click, but dont know how to focus in firefox.

in explorer it is ok:

var iframe_window = window.frames["myFrame"];
iframe_window.document.body.focus();

try lot of examples for firefox, but they dont work. anybody know how to do it in firefox ? thanks.

A: 

Does

iframe_window.contentDocument.body.focus();

work?

Justin Wignall
no, it does nothing
mm
How about when using var iframe_window = document.getElementById('myFrame');having myFrame as the id attribute on the iframe?
Justin Wignall
yes, i have 'myFrame' as the id attribute and also as name attribute, but it still doesnt work
mm
A: 

hi,

have you resolved your problem ? i'm facing a similar issue. when opening the master page (= the one containing the iframe) first, ff 3.5 wouldn't set focus inside the slave page ( = the one the iframe contains). any subsequent calls to set the slave focus succeed.

any ideas ?

let me know if you need more info.

thx in advance

regards, carsten

Carsten Beck
hi, dont'k know how :( still didnt resolve it
mm
A: 

I think you might have to actually focus something inside the iFrame; the iFrame itself wouldn't do anything with the focus, but maybe you can put focus a DIV inside it, or even a widget?

Ken
A: 

hi, try to set the focus to 'iframe_window' first and to your actual content next:

iframe_window.focus(); iframe_window.contentDocument.body.focus();

hth, regards, carsten

Carsten Beck
A: 

Try setting the focus to the <iframe> element itself.

Neil