Focus on the element inside iFrame onLoad?

So, I have an iFrame that contains a form. I would like the page to focus on the input element "foo" when the page loads. Is there any way to do this?

+3
source share
1 answer

if your iframe has an src attribute with the same domain as the parent document, then it is simple:

<iframe src=" ... " onload="document.getElementById('foo').focus();"></iframe>

, " ":

1. iframe ( , javascript), , ( : http://softwareas.com/cross-domain-communication-with-iframes)
2. 3- - iframe,
( dns + document.domain , )

+1

All Articles