So I have an iFrame that contains a form. I would like for the page to focus in on the input element “foo” when the page loads. Is there a way to do this?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
if your iframe has src attribute with the same domain as the parent document then it is simple:
but if not, then you have a problem with ‘same origin policy’:
1. if you have access to modify document inside iframe (I mean if you can add some javascript code there) it’s a bit tricky but possible (here’s a good article about that: http://softwareas.com/cross-domain-communication-with-iframes)
2. if you have a 3-rd party website inside your iframe then it is imposible
(the only way is to use some dns+document.domain tricks but they are extremely ugly)