iframe父子页面间的关系

在hbBank项目中,客户信息查询使用了, iframe引入外界的页面,使用代码如下:

<iframe id="tab-3" class="hidden" name="tab-3" marginwidth=0 marginheight=0 width=100%  src="../commomFile/otherBorrInfo.html" frameborder=0>
</iframe>

 <iframe scrolling="no" frameBorder=0 id=frmchild1 name=frmchild1 height="400"
        src="childPage1.html" width="100%" allowTransparency="true"></iframe>//这是另一种的,未验证

子页面 调用父页面的方法; parent.methodName(); 或者top.methodName();


parent是上一级, top 是最上一级, 但是子页面一般是二级页面,所以可以使用top ,但是如果子页面是第三级页面,请你使用parent;




如果是子页面之间的方法互调;格式:: parent.子页面.methodName; 或者top.子页面.methodName;


总而言之;iframe关于父子,兄弟直接的方法或者属性调用均是 通过 parent或者 top 实现;
原文地址:https://www.cnblogs.com/chenlongsheng/p/10097386.html