Today, let's summarize the differences and usage of several objects in Javascript. If you are confused about these concepts, let's take a look at the differences and usage of several objects in javascript:
First, the usage of parent. window and top. window
"Window. location. href" and "location. href" indicate the current page Jump.
"Parent. location. href" is the previous page Jump
"Top. location. href" is the outermost page Jump
Example:
If A, B, C, and D are all jsp, D is the iframe of C, C is the iframe of B, and B is the iframe of A, if js in D is written like this
"Window. location. href", "location. href": D page Jump
"Parent. location. href": C page Jump
"Top. location. href": A page Jump
Now I understand the usage of target during connection:
_ Blank: open a new window
_ Parent: the parent window is redirected.
_ Self: Page redirection
_ Top: redirection of the first parent window
In conclusion, parent. window: parent window object top. window: first parent window object
Next, let's take a look at the differences between window. parent and window. openner.
Window. parent is the parent page object called by the iframe page. When we want to access the outer page from the embedded page of iframe, we can directly use window. parent to obtain it;
Example:
A.html
The Code is as follows:
Parent page
B .html
The Code is as follows: