`

iframe调用子iframe的方法,子调用父iframe的方法

    博客分类:
  • js
阅读更多

在index.html页面中有

 <script type="text/javascript">
  function test(){
   alert('test() success!');
  }
 </script>

<body>
    <a href="#" onclick="frame1.window.childFunction();">调用</a>
      <iframe name="frame1"   src="test1.html"/>
      <iframe name="frame2"   src="test2.html"/>
  </body>

在test1.html页面中有

<script type="text/javascript">
  function childFunction(){
   alert('test childFunction() success!');
  }
 </script>

<body>

<a href="#" onclick="parent.test();">调用</a>

</body>

iframe调用子iframe的方法:parent.test()

子调用父iframe的方法:frame1.window.childFunction()

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics