How can i call a window child function in javascript?

Jonathan picture Jonathan · Dec 19, 2012 · Viewed 24.5k times · Source

I am calling the parent function like window.parent.functionname(); from the child page. How can i call the window.child.function() from the parent page to child page.

Any help is appreciated.

Answer

Bruno picture Bruno · Dec 19, 2012

Give your iFrame an id and try

document.getElementById("iFrameId").contentWindow.functionname()

This works even when you have multiple iFrames in the same page irrespective of their order.