Heim  >  Artikel  >  Web-Frontend  >  JS window对象的top、parent、opener含义介绍_javascript技巧

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

WBOY
WBOYOriginal
2016-05-16 17:11:001158Durchsuche

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;

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn