How to use Window.location.href

Source: Internet
Author: User

http://hljqfl.blog.163.com/blog/static/40931580201122210573364/

In the writing of the ASP, we often encounter the problem of jump page, we often use Response.Redirect to do ASP. NET Frame page jump, assuming that the customer to use the prompt when jumping, this is not an inspiration, such as:

Response.Write ("< Script>alert (' Congratulations, register success!  ');</script> "); Response.Redirect ("main.html");

At this time our cue content did not come out on the jump, and Response.Redirect ("main.html"); no matter what the difference.

At this point we experimented with the following code:

Asp. NET Framework page jump also has an implementation

Response.Write ("< script Language=javascript>alert (' Congratulations, register success!  ') </script> "); Response.Write ("< script language=javascript>window.location.href= ' main.html ' </script>");

This is the implementation of our requirements, after the prompt, jump page.

The most important thing is that the WINDOW.LOCATION.HREF statement is able to implement a framework page that refreshes after running the server-side code with a frame of the page (Response.Redirect cannot be reached, at least I have not found):

For example: The index.htm page has two frames, frameleft and frameright, respectively, and refreshes the pages in Frameleft after running the server-side code in the Frameright page.

Before the most common is the Register, self-refresh the landing box, let the landing box for the landing page, just to add a paragraph after the successful code, that is, the ability to refresh another frame of the page. The code is as follows:

Response.Write ("< script Language=javascript>alert (' Congratulations, register success!  ') </script> "); Response.Write ("< script language=javascript>window.parent.frameleft.location.href= ' main.html ' </script > ");

This will take care of the problem of the ASP page jump interruption.

=====================================================================================

"Window.location.href", "location.href" is this page jump

"Parent.location.href" is a page jump on the previous level

"Top.location.href" is the outermost page jump

To illustrate:

Assuming that a,b,c,d are Jsp,d is C iframe,c is B's iframe,b is an IFRAME, assuming D JS so write

"Window.location.href", "location.href": D page Jump

"Parent.location.href": C page Jump

"Top.location.href": a page jump

Assuming that the D page has a form,

<form>: After form submission D page jump

<form target= "_blank";: New page pops up after form submission

<form target= "_parent";: C page jump after form submission

<form target= "_top" >: Form submitted after a page jump

About page refreshes, this is written in the D page:

"Parent.location.reload ();": C page Refresh (of course, you can also use the opener object of the subform to get the object of the parent form: Window.opener.document.location.reload (); )

"Top.location.reload ();": a page refresh

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.