1, Window.parent is the IFRAME page called the parent Page object
Example: a.html
<body>
<form name= "Form1" Id= "Form1" >
<input type= "text" name= "username" id= "username"/>
</form>
<iframe src= "b.html" width=100%></iframe>
</body>
If we need to assign a value to the Username text box in the a.html (like many upload functions, upload function page in the Ifrmae, upload the path after uploading the b.html in the parent page text box), we should write in the b.html:
<script type= "Text/javascript" >
var _parentwin = window.parent;
_parentwin.form1.username.value = "XXXX";
</script>
Z-blog's article editing page upload function is so realized.
2. Window.opener is the parent page object called by window.open open child page
Opener: A reference to the Window object that opens the current window whose value is null if the current window is opened by the user.
Self represents its own window, and opener represents the window that opens itself, such as the Window a.html open window b.html. If you rely on the Window.Open method, the window b.html,self represents b.html itself, and the opener represents the window a.html.
Example: a.html
<input type= "text" name= "username" id= "username"/>
<a onclick= "window.open (This.href, ' ', ' resizable=yes,width=800,height=600,status '); return false "href=" b.html ">B</a>
If you need to assign a value to a FORM element in a.html in b.html, we should write this in b.html
<a href= "Javascript:try{window.opener.document.getelementbyid (' username '). Contentwindow.
Frames[0].document.getelementsbytagname (' body ') [0].innerhtml+= ' xxx '}catch (e) {};window.close (); " > Insert </a>
The
Closes the b.html with Window.close later. Windsphoto 2.7.3 in the article edit page pop-up new window (Picture list), choose to insert the uploaded image is so implemented.