First, let's take a look at several location types. the differences between href and href are as follows. differences between href and js implement the iframe framework function of a webpage. If you are interested, please take a look at the following: window. location. href, location. href, self. location. href, parent. location. href, top. location. href their differences and relationships, Simply put: Several location. differences between href and js implement the function of webpage iframe framework
"Window. location. href", "location. href", and "self. location. href" are displayed on the current page.
"Parent. location. href" is the previous page Jump
"Top. location. href" is the outermost page Jump
For example ):
If A, B, C, and D are common pages, D is the iframe of C, C is the iframe of B, and B is the iframe of,
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
If form exists on Page D:
: Jump to the D page after the form is submitted
: A New Page is displayed after form is submitted.
: C page jump after form is submitted
: Jump to page A after form is submitted
For page refresh, write the following in page D:
"Parent. location. reload (); ": refreshes the C page (of course, you can also use the opener object of the Child Window to obtain the parent window object: zookeeper opener.doc ument. location. reload ();)
"Top. location. reload ();": page A is refreshed.
Now let's take a look at it. It's easy to implement the function of JavaScript to prevent webpages from being put into the iframe framework. If the framework of the content.html file is set in the frame.html file, the idea is as follows: add js in content.html to check whether the top. location. href address is the top. location. href address. If yes, It is not nested. If no, It is nested. This is a prompt.