The pages in frame frames should be changed to other pages in the frame or the parent frame with parent
Window.opener refers to the parent page of the window.open open page.
The Window.frames object can refer to the page in the IFRAME, or to the page in the frameset.
Can do this
| The code is as follows |
Copy Code |
| Window.frames[0].document.getelementbyid (' xx '); |
Can do this
| The code is as follows |
Copy Code |
window.frames[0].document.body.innerhtml; frm = window.parent.window.frames[' uploadframe ']; Frmdocument = frm.document; FRM.SB (3); SB is a function in the Uploadframe page |
For Firefox
If you encounter an error: Parent.document.frames has no properties
Replace it with the following code, this code is IE,FF compatible. frm = window.parent.window.frames[' uploadframe '; in fact, the frames collection is not hanging in the document but hanging under the Window object.
Note that there is a limit to the page in the frame, which must be under the same domain, otherwise inaccessible
If it is under the same domain, but the sub domain name is different, then the js,html file involved adds a sentence.
Document.domain = xxx.com [fill in your domain name here]
| The code is as follows |
Copy Code |
| document.getElementById (' Iframeid '). ContentWindow.document.getElementById (' Someelementid '); |
Parent.window examples are as follows:
Example:
A.html
| The code is as follows |
Copy Code |
<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 be in the b.htm to a.htm in the username text box, such as a lot of upload function, upload function page in Ifrmae, upload success after uploading the path into the parent page text box
We should write in b.html.
| The code is as follows |
Copy Code |
<script type= "Text/javascript" > var _parentwin = window.parent; _parentwin.form1.username.value = "XXXX"; </script> |
Window.opener is a window.open or hyperlink <a> open subpage Call parent Page object
examples are as follows
A.html
| The code is as follows |
Copy Code |
<title> Parent Page </title> <script type= "Text/javascript" > function Openb () { window.open (' b.html ', ' B ', ' width=400,height=200,status=no,toolbar=no,menubar=no,location=no,resizable=yes,left= 200,top=100 '); } </script> <body> <form id= "Form1" action= "" > <div>
|
Enter a value:
| The code is as follows |
Copy Code |
<input type= "text" name= "username" id= "username"/><br/> <input type= "button" value= "open Window B" onclick= "Openb ();"/><br/> <a href= "b.html" target= "_blank" > Hyperlinks Open b page </a> </div> </form> </body> |
B.html
| code is as follows |
copy code |
| <script type= "text/javascript" > Function Getpvalue () { Document.getelemen Tbyidx_x_x_x ("Span1"). Innertext=window.opener.document.getelementbyidx_x_x_x ("username"). Value; } </script> <body> <span> text box value: </span><span id= "Span1" ></span><br/> <input type= button "value=" gets the text box value "onclick=" Getpvalue () in the parent window; > </body> |
window.parent The simple use of foreign countries
Syntax
Window.parent.frames[num]
Window.parent.frameName
The Parent property contains a reference to the parent window.
The referencing of these sibling frames can either being done using the frames array, or the name this is assigned by the NAM E attribute of the tag.
var myframereference = mywin.parent.frames[2];
To sum up briefly
Sub page:
/aaa/aaa.html
Parent page:
/bbb/bbb.html
The code in the sub page is as follows
parent.window.location= "Ccc.html"
Results:
Parent page Jump to:
/aaa/ccc.html
Opener: A reference to the Window object that opens the current Windows, and its value is null if the current window is opened by the user.
Self: The self-referencing property, which is the application of the current Window object, is synonymous with the Window property.
The
Self represents its own window, and opener represents the window that opens itself, such as window a opens window B. If you rely on the Window.Open method, the window b,self represents B itself, and opener represents window a.