
加载一个iframe
<iframe id="son" src="a.html"></iframe>
iframe里边的内容
<body>
这是子页面
<script>
function test() {
console.log("子页面的方法");
}
</script>
</body>
这样调用即可
document.getElementById('son').contentWindow.test();
注意:需要iframe加载完毕后才能调用哦,不然会找不到的
评价