日期:2014-05-16  浏览次数:20456 次

Jquery如何在iframe父窗体中调用子窗体的函数
RT如题:

假如有一个test.htm用的是JUQERY框架。在test.htm页面里有一个iframe控件和一个按钮<button onclick="" id="btn"></button>。

iframe引用ifm.htm页面。而这个子窗体页面(ifm.htm)中有个函数function test(){alert('子窗体弹窗');} ;

请问,如何在test.htm主页面中,点击这个按钮就能执行到子窗体的test()函数呢?

注意:是用Jquery实现哦。。。。

谢谢高手了。。。。
test.htm页面:
<iframe src="ifm.htm" id="mainfrm"></iframe>
<button onclick="" id="btn"></button>

ifm.htm页面:
<script>
function test()
{
alert("test");
}
</script>

------解决方案--------------------
$("#mainfrm")[0].contentWindow.test();