iframe 子页面调用父页面方法 父页面调用子页面方面 iframe页面通信

1.子页面调用主页面方法

1. function transfer(){}//父页面方法

2. parent.transfer();//子页面调用

2.父页面调用子页面的方法

<iframe id="common-iframe"></iframe>

var childItem = $("#common-iframe")[0].contentWindow; //拿到子窗口的对象 ("#common-iframe) iframe的id

function receive(){}//子页面方法

childItem.receive();//调用子窗口的方法

 

posted @ 2020-10-15 21:16  虹猫淘气  阅读(500)  评论(0编辑  收藏  举报