Search code examples
javascriptframes

How can i call a window child function in javascript?


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.


Solution

  • 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.