Home > Web Front-end > JS Tutorial > About the usage and difference of window.location.href, location.href, parent.location.href, top.location.href in js_javascript skills

About the usage and difference of window.location.href, location.href, parent.location.href, top.location.href in js_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 18:18:12
Original
1302 people have browsed it

"window.location.href" and "location.href" are the jumps to this page

"parent.location.href" are the jumps to the previous page

"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 A's iframe, if the js in D writes

"window.location.href", "location.href": D page jumps to

"parent.location.href": C page Jump

"top.location.href": Jump to page A

If there is a form in page D,

: Jump to page D after the form is submitted. Go to

: A new page pops up after the form is submitted

: Page C jumps after the form is submitted

: Page A jumps after the form is submitted Go to

Regarding page refresh, write this in D page:

"parent.location.reload();": C page refresh (of course, you can also use the opener object of the child window to obtain Object of the parent window: window.opener.document.location.reload(); )

"top.location.reload();": A page refresh
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
mysqldump without specifying location
From 1970-01-01 08:00:00
0
0
0
web - nginx location search algorithm problem! ?
From 1970-01-01 08:00:00
0
0
0
nginx location matching problem
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template