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.

Naftali
  • 144,921
  • 39
  • 244
  • 303
Rizwan
  • 11
  • 1
  • 1
  • 2
  • Try: http://stackoverflow.com/questions/3672726/make-an-event-happen-in-child-iframe-to-the-parent-window-in-javascript – Meetai.com May 28 '13 at 03:50

2 Answers2

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

frameOne should be the ID of the frame!

ChristianB
  • 1,967
  • 14
  • 25
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

Naftali
  • 144,921
  • 39
  • 244
  • 303
  • I am using a relative path as src of iframe. Doesn't it mean that it is on the same domain as parent?? – Rizwan May 26 '11 at 16:55