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.
If you're trying to set focus to an element in an iframe that has already been loaded, you need to set focus to the iframe first, then to the element. myField. focus();
You can change this behaviour in your own Firefox installation by typing about:config in the address bar and setting security. mixed_content. block_active_content to false .
Definition and UsageThe <iframe> tag specifies an inline frame. An inline frame is used to embed another document within the current HTML document. Tip: Use CSS to style the <iframe> (see example below). Tip: It is a good practice to always include a title attribute for the <iframe> .
Try to set the focus to iframe_window
first and to your actual content next:
iframe_window.focus();
iframe_window.contentDocument.body.focus();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With