Usage and difference of window. location. href, location. href, parent. location. href, top. location. href in js _ javascript skills

Source: Internet
Author: User
Window. location. href, location. href, parent. location. href, top. location. href usage "window. location. href "," location. href "is 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

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.