1

How can I call a javaScript function present in a child <iframe> node from the parent? I am using jquery selector to select the correct iframe node but do not know how to call the function. Also the desired iframe has been added dynamically using jquery.

For example, the iframe is

<iframe id="frameOne" src="http://form_one.html"><iframe>

I need to do something like this

$(#frameOne).submitList();

where submitList() is a function in form_one.html.

Thanks.

1

2 Answers 2

6
document.getElementById('frameOne').contentWindow.submitList();

frameOne should be the ID of the frame!

Sign up to request clarification or add additional context in comments.

2 Comments

I get the following in firebug $("#frameOne").contentWindow is undefined.
sorry - it only works with document.getElementById('frameOne').contentWindow.submitList();
0

As long as both of the URLs are in the same domain it should work.

If they are not, then you run into cross-domain issues

1 Comment

I am using a relative path as src of iframe. Doesn't it mean that it is on the same domain as parent??

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.