Window.parent and the difference window.opener

Today saw the company's development bank, people sometimes abuse found inside two stuff, feel the need to sort out

 

window.parent: iframe page call the parent page object

a.html

< html >
< head >< title >父页面 </ title ></ head >
< body >
< form  name ="form1"  id ="form1" >

< input  type ="text"  name ="username"  id ="username" />

</ form >
< iframe  src ="b.html"  width =100% ></ iframe >
</ body >
</ html >

 

 

If we need to be on a.htm the username text box assignment in b.htm in, just like a lot of uploading, upload page in the I frmae, the upload was successful uploaded into the path of the parent page text box

we should be written in the b.html
<Script
type = "text / JavaScript">
var = _parentWin window.parent;
_parentWin.form1.username.valu E = "XXXX";
</ Script>

 

window.opener is window.open to open a sub-page call the parent page object

 

opener: open window for the object reference to the current window, if the user opens the current window, it is null.

self: self-referential properties, application, and window attributes synonymous with the current window object.

self own behalf window, opener representatives opened the window itself,

B A window such as the window opens, for window B, Self represents B themselves, and the representative of the window opener A.

 


Reproduced in: https: //www.cnblogs.com/davidgu/archive/2012/08/30/2663166.html

Guess you like

Origin blog.csdn.net/weixin_33860147/article/details/93802820