您的位置:首页 > Web前端 > JavaScript

JS window对象的top、parent、opener含义介绍

2016-03-18 10:21 1106 查看


JS window对象的top、parent、opener含义介绍

作者: 字体:[增加 减小] 类型:转载 时间:2013-12-03 我要评论

本文为大家介绍下JS window对象的top、parent、opener含义,不了解的朋友可以参考下,希望对大家有所帮助

<iframe id="iframeu2261530_0" src="http://pos.baidu.com/hcvm?sz=680x200&rdid=2261530&dc=2&exps=112101&di=u2261530&dri=0&dis=0&dai=2&ps=424x27&coa=at%3D3%26rsi0%3D680%26rsi1%3D200%26pat%3D6%26tn%3DbaiduCustNativeAD%26rss1%3D%2523FFFFFF%26conBW%3D1%26adp%3D1%26ptt%3D0%26titFF%3D%2525E5%2525BE%2525AE%2525E8%2525BD%2525AF%2525E9%25259B%252585%2525E9%2525BB%252591%26titFS%3D14%26rss2%3D%2523000000%26titSU%3D0%26ptbg%3D90%26piw%3D0%26pih%3D0%26ptp%3D0&dcb=BAIDU_SSP_define&dtm=BAIDU_DUP_SETJSONADSLOT&dvi=0.0&dci=-1&dpt=none&tsr=0&tpr=1458267369624&ti=JS%20window%E5%AF%B9%E8%B1%A1%E7%9A%84top%E3%80%81parent%E3%80%81opener%E5%90%AB%E4%B9%89%E4%BB%8B%E7%BB%8D_javascript%E6%8A%80%E5%B7%A7_%E8%84%9A%E6%9C%AC%E4%B9%8B%E5%AE%B6&ari=1&dbv=2&drs=1&pcs=1045x619&pss=1045x430&cfv=0&cpl=4&chi=1&cce=true&cec=GBK&tlm=1457110188&ltu=http%3A%2F%2Fwww.jb51.net%2Farticle%2F44078.htm&ltr=http%3A%2F%2Fwww.jb51.net%2Farticle%2F45626.htm&ecd=1&psr=1366x768&par=1366x728&pis=-1x-1&ccd=24&cja=false&cmi=6&col=zh-CN&cdo=-1&tcn=1458267370&qn=450f4165edd41dea&tt=1458267369603.54.184.189" width="680" height="200" align="center,center" vspace="0" hspace="0" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" allowtransparency="true" style="display: block; border-width: 0px; border-style: initial; vertical-align: bottom; margin: 0px;"></iframe>

1.top

该变更永远指分割窗口最高层次的浏览器窗口。如果计划从分割窗口的最高层次开始执行命令,就可以用top变量。 

2.opener

opener用于在window.open的页面引用执行该window.open方法的的页面的对象。例如:A页面通过window.open()方

法弹出了B页面,在B页面中就可以通过opener来引用A页面,这样就可以通过这个对象来对A页面进行操作。 

3.parent

parent用于在iframe,frame中生成的子页面中访问父页面的对象。例如:A页面中有一个iframe或frame,那么iframe

或frame中的页面就可以通过parent对象来引用A页面中的对象。这样就可以获取或返回值到A页面中。

4.另外self 指的是当前窗口

parent与opener的区别:

parent指父窗口,在FRAMESET中,FRAME的PARENT就是FRAMESET窗口。 

opener指用WINDOW.OPEN等方式创建的新窗口对应的原窗口。 

parent是相对于框架来说父窗口对象 

opener是针对于用window.open打开的窗口来说的父窗口,前提是window.open打开的才有

document.parentWindow.menthod()調用父頁面的方法

附:Window对象、Parent对象、Frame对象、Document对象和Form对象的阶层关系 

Window对象→Parent对象→Frame对象→Document对象→Form对象,

如下: parent.frame1.document.forms[0].elements[0].value;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: