JS中的top是什么?

<iframe/>或者<frame>里面用主页面的东西,就是top.xxx

如:
<script>
  function func(){ ... };
</script>
<input type='text' id='t' />
<iframe scr='a.html'/>

//a.html简单内容如下
<script>
top.document.getElementById('t').value; //在a.html中取input的值
top.func(); //在a.html中执行func()
</script>

转载于:https://www.cnblogs.com/jieliujas/p/8961236.html

posted @ 2022-06-30 17:35  曲琦  阅读(1331)  评论(0编辑  收藏  举报