Refresh the page and go back

Source: Internet
Author: User
How to refresh the page with javascript:
1. History. Go (0)
2. Location. Reload ()
3. Location = Location
4. Location. Assign (location)
5. document.exe ccommand ('refresh ')
6. Window. navigate (location)
7. Location. Replace (location)
8.doc ument. url = location. href success ------------------------------------------------------------------------------------------------------ Differences between window. Location. Reload () and window. Location. href = Window. Location. href;

<A onclick = "javascript: window. Location. href = Window. Location. href;">

<A onclick = "javascript: window. Location. Reload ();">

The test results are the same. The form is not submitted.

<Input type = "Submit" onclick = "javascript: window. Location. Reload ();" value = "click" id = "btnvcode"/>
<Input type = "Submit" onclick = "javascript: window. Location. href = Window. Location. href;" value = "click" id = "btnvcode"/>

Submit data

 

Window. Location. Reload () should be refreshed. (If data is submitted, the system will prompt whether to submit (yes and no ))
Window. Location. href = Window. Location. href;

It is recommended that you do not use location. Reload (), but use location = location, and use showmodaldialog and showmodelessdialog in the mode window.

 

The reload parameters include true and false. Is it interesting?

 

-----------------------------------------------------------------------------

 

The two methods are used to refresh the parent window, but there are still some mysteries.
Window. opener. location. reload (); when this method forces the parent window, a confirmation dialog box is displayed in some ie browsers (such as high security settings, it prompts if you want to refresh the page again. This is a depressing thing. I later replaced this method with window. opener. location. href = Window. opener. location. href;
This will not happen. --------------------------------------------------------------------------- In <body onUnload = "window. opener. location. reload (); "> in this way, the main window --------------------------------------------------------------------------" Forward "and" backward "function back () is automatically refreshed when the subwindow is destroyed ()
{
Window. History. Back ()
}
Function forward ()
{
Window. History. Forward ()
}
Function back2 ()
{
Window. History. Go (-2)
}
Function forward2 ()
{
Window. History. Go (2)
}
-----------------------------------------------------------

JS refresh window: window. Location. Replace (window. Location. href)

Window. Location. Reload ();

Window. History. Go (0 );

Window. Location. Assign (window. Location. href)

Window. Location. hrefAnd window. Location. RepDifferences between shards:

1. html-> 2.html-> 3.html

After the system starts from 1.html to 2.html, there are two buttons in 2. btn1is named w.location.href1_3.html, btn2is named window.location.replace(3.html), then,

When you click btn2to enter 3rd, use unzip history.go(-1##wondo=history.back(); to return 2.html

 

--------------------------------------------------------

Experience and differences between window. Location. href and window. Location. Replace

When window. Location. href is used, window. History. Go (-1) or window. History. Back () is used.

When window. Location. Replace ('url') is used, window. History. Go (-1) or window. History. Back () is not used.

Window. Location. Replace ("3.jsp"); is a jump that does not send a request to the server.

Window. History. Go (-1); window. History. Back (); the method is to decide which page to jump to based on the request recorded by the server.

Window. location. href ("3.jsp"); is the redirect request sent to the server, window. history. go (-1); wondow. history. the back () method determines the page to jump to based on the request recorded by the server

There are 3 JSP pages (1.jsp, 2.jsp, 3.jsp), which are 1.jsp by default in the system. When I enter 2. in JSP, 2. window is used in JSP. location. replace ("3.jsp. location. href ("3.jsp"); from the user interface, there is no difference, but when 3. the JSP page has a "return" button that calls window. history. go (-1); wondow. history. back (); when the method is used, the return button will return 2. JSP page, the difference will come out, when the window is used. location. replace ("3.jsp"); Connect to 3. JSP page, 3. call window on the JSP page. history. go (-1); wondow. history. back (); method is not easy to use and will return to 1.jsp. When window. location. href ("3.jsp"); Connect to 3. JSP page, 3. call window on the JSP page. history. go (-1); wondow. history. back (); The method is easy to use and will return 2.jsp. Because window. location. replace ("3.jsp"); does not send a jump request to the server, while window. history. go (-1); wondow. history. the back () method determines the page to jump to based on the request recorded by the server, so it will jump to the system default page 1.jsp. Window. location. href ("3.jsp"); is the redirect request sent to the server, window. history. go (-1); wondow. history. the back () method determines the page to jump to based on the request recorded by the server, so you can return to 2.jsp.

 

--------------------------------------------------------

 

<InputType = buttonValue = RefreshOnclick = "window. Location. Reload ()">
 <InputType = buttonValue = forwardOnclick = "window. History. Go (1)">
 <InputType = buttonValue = backwardOnclick = "window. History. Go (-1)">
 <InputType = buttonValue = forwardOnclick = "window. History. Forward ()">
 <InputType = buttonValue = backwardOnclick = "window. History. Back ()">

Back + refresh <InputType = buttonValue = backwardOnclick = "window. History. Go (-1); window. Location. Reload ()">
In the C # web program, for example, for the page button writing back to the previous page code

This. registerclientscriptblocK ("e", "<script language = JavaScript> history. Go (-2); </SCRIPT> ");

Among them, history. Go (-2) should be written as-2. Because the page has been refreshed once before the button event is triggered, it should be-2.

Response. Write ("<script language = JavaScript> history. Go (-2); </SCRIPT> ");

It must also be written as "-2 ". It is different from writing scripts directly.History. Back () is the previous page
I = 1
History. Go (I) goes to a specified night
If it is history. Go (0), it is to refresh these two JS codes, which is equivalent to IE's forward and backward functions.
The specific use depends on when this is needed. For example, the user registration verification is background verification, and this can be used when the user does not meet the requirements, to ensure that the user does not input data repeatedly to the maximum extent.
For example, load a page:
Function onloadpage (){
If (event. srcelement. tagname = "span "){
Oframe = top. Window. Middle. Frames [2];
Otxt = event. srcelement. innertext;
Switch (otxt ){
Case "Forward ":
Oframe. History. Go (1 );
Case "back ":
Oframe. History. Back ();
Case "refreshing ":
Oframe. Location. Reload ();
}
}
}

 

Related Article

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.