How to call javascript function specified in a child <frame>

Check for contentWindow, contentDocument and get the frame object and perform call.

var siblingFrame;
if (parent.document.getElementById('siblingFrameId').contentWindow){
  siblingFrame = parent.document.getElementById('siblingFrameId').contentWindow;
} else if (parent.document.getElementById('siblingFrameId').contentDocument){
  siblingFrame = parent.document.getElementById('siblingFrameId').contentDocument;
} else if (parent.document.getElementById('siblingFrameId')) {
  siblingFrame = parent.document.getElementById('siblingFrameId');
}

siblingFrame.helloWorld();

You can call method from childframe

window.frames[n].frames[m].methodName()

where n , m are integers starting from 0.If you have document only one frame remove the frames[m] part and get the job done.

Ya one more thing , do trial an error and find out exact frame numbers and method. Hope this helps


You can do it like this:

document.getElementById('frame3').contentWindow.helloWorld();