Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access function inside an iFrame

Status
Not open for further replies.

sharapov

MIS
May 28, 2002
106
US
How can I access function located inside an iFrame. In other words, I have a page with an iframe in it. the iframe has a function. the main page has a button. What I want to do is when user presses on the button the function inside an iframe should execute.
I tried to accesess an iframe the following way without any luck.

document.frames("myiFrame_name").document.some_function();

Can anybody help?
 
Code:
document.getElementById("myiFrame_name").contentWindow.some_function();

May bring you more luck.
 
window.frames.frmiFrame.myfunctioninframe(arg0, arg1);

frmiFrame is the name of the iFrame

myfunctioninframe is the name of the function inside the iframe that accepts 2 arguments.

If you load different pages into the iframe, make sure all of them have the functions "myfunctioninframe(arg0, arg1)" declarations" Else you will get a syntax error since it cannot find the function on the page inside iframe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top