iframe の親ページが子ページのメソッドを呼び出す

サブページ.html

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://lib.sinaapp.com/js/jquery/ 1.7.2/jquery.min.js" type="text/javascript"></script>   
<script type="text/javascript">
$(function(){ $('.selectAll').click(function( ){     $('input[name="チェック項目"]').prop('チェック済み',this.チェック済み); } )


 window.parent.parentHello();
})
 functionsonHello() {             alert("これは息子の hello 関数です!");         }

</script>
</head>
<body>
<div>
<input type="checkbox" class="selectAll" name="selectAll">全选 
<input type="checkbox" name="check-item" οnclick= "全て();" /> 周一
<input type="checkbox" name="check-item" οnclick="all();" /> 周一
<input type="checkbox" name="check-item" οnclick="all();" /> 周一
<input type="checkbox" name="check-item" οnclick="all();" /> 周一
<input type="checkbox" name="check-item" οnclick="all();" /> 一周
</div>


</body>
</html>

 

親ページ.html

 

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script src="http://lib.sinaapp.com/js/jquery/ 1.7.2/jquery.min.js" type="text/javascript"></script>   
<script type="text/javascript">

$(function(){   $('#father').click(function(){     myframe.window.sonHello();   })


})
 functionparentHello() {             alert("これは親の hello 関数です!");         }       // window.frames[0].sonHello();



</script>
</head>
<body>
<div>
<button id="father">点击</button>
<iframe src="checkall.html" name="myframe"></iframe>
</div>


</body>
</html>

おすすめ

転載: blog.csdn.net/weixin_42835381/article/details/109330239