Window. location. href usage (Dynamic Output jump), window. location
Location. href in javascript has many usage methods, mainly as follows.
Self. location. href = "/url" the current page opens the URL page
Location. href = "/url" the current page opens the URL page
Windows. location. href = "/url": the current page opens the URL page. The previous three operations are the same.
This. location. href = "/url" the current page opens the URL page
Parent. location. href = "/url" opens a new page on the parent page.
Top. location. href = "/url" opens a new page on the top page.
If the frame is customized on the page, you can replace parent self top with the name of the custom frame to open the url address in the frame window.
In addition, window. location. href = window. location. href; and window. location. Reload () both refresh the current page. The difference is whether data is submitted. When data is submitted, window. location. Reload () will prompt whether to submit. window. location. href = window. location. href; then the data is submitted to the specified url.
Write ASP. net program, we often encounter page Jump problems, we often use Response. redirect for ASP. NET Framework page Jump, if the customer wants to use the prompt when the jump, this is not a good thing, such:
Copy codeThe Code is as follows:
Response. Write ("<script> alert ('Congratulations, registration successful! '); </Script> ");
Response. Redirect ("main.html ");
At this time, our prompt content will jump without coming out, and there is no difference with Response. Redirect ("main.html.
Then we use the following code to test:
Another implementation of ASP. NET Framework page Jump
Copy codeThe Code is as follows:
Response. Write ("<script language = javascript> alert ('Congratulations, registration successful! ') </Script> ");
Response. Write ("<script language = javascript> commandid location.href+'main.html '</script> ");
This allows us to jump to the page after the prompt.
The most important thing is that the window. location. href statement can implement a framework page, refresh the page of another framework after executing the server code (Response. Redirect cannot be reached, at least I did not find it ):
For example, the index.htm page has two frameworks: frameLeft and frameRight. On the frameRight page, execute the server code and refresh the page in frameLeft.
Previously, the most common issue was to automatically refresh the login box after registration and change the login box to the logged-on page. You only need to add a section after the successfully registered code, that is, you can refresh the page of another framework. The Code is as follows:
Copy codeThe Code is as follows:
Response. Write ("<script language = javascript> alert ('Congratulations, registration successful! ') </Script> ");
Response. Write ("<script language = javascript> Response parent.frameleft.location.href+'main.html '</script> ");
In this way, the ASP. NET Framework page Jump interruption is solved. This method is generally used in asp and php.
"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
If form exists on Page D,
<Form>: Jump to the D page after the form is submitted
<Form target = "_ blank">: a new page is displayed after the form is submitted.
<Form target = "_ parent">: C page jump after form is submitted
<Form target = "_ top">: 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.
Windowlocationhref usage
Missing & Symbol:
Here is an example:
<Script language = "javascript">
Zookeeper Doc ument. location. href = "./admin_index.asp? UserName = "& request (" patientname ") &" & patientnumber = "& request (" patientnumber "); </script>
Take a closer look:
It should be:
Window. location. href = "B. asp? Dr = "+ a +" & drr = "+ c;
Is windowlocationhref a js jump?
Window. location. href = URL: Jump to the URL page