如何在父母的iframe中调用func?

时间:2014-02-18 09:18:57

标签: javascript html iframe

我想在iframe中调用func,来自父级。 如果func在父级中,我可以将其称为:parent.func(); 但我想调用iframe中的func,我想从父母那里调用它? js说我找不到功能?我怎么称呼它?

感谢

2 个答案:

答案 0 :(得分:1)

尝试

window.frames['childFrame'].func();

document.getElementById('childFrame').contentWindow.func();

答案 1 :(得分:1)

你可以这样做,

的document.getElementById( '框架')contentWindow.helloWorld();

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