The difference between javascript:history.go () and History.back () and its application _javascript techniques

Source: Internet
Author: User
Copy Code code as follows:

<input Type=button value= Refresh onclick= "Window.location.reload ()" >
<input Type=button value= forward onclick= "Window.history.go (1)" >
<input Type=button value= back onclick= "Window.history.go ( -1)" >
<input Type=button value= forward onclick= "Window.history.forward ()" >
<input Type=button value= back onclick= "Window.history.back ()" > Back + refresh <input Type=button back value= " Window.history.go ( -1); Window.location.reload () ">

In a C # Web program, such as returning the previous page of code for a page button write
Copy Code code as follows:

This. RegisterClientScriptBlock ("E", "<script language=javascript>history.go ( -2);</script>");

Where, History.go (-2) is written as-2, the page is refreshed once before the button event is triggered, so it should be-2.
Copy Code code as follows:

Response.Write ("<script language=javascript>history.go ( -2);</script>");

This is also written as "-2". differs from direct write scripts. History.back () is the previous page
Copy Code code as follows:

I=1
History.go (i)
[HTML]
Go to the specified page
If it is history.go (0) that is refreshing these two belong to JS code, the equivalent of IE forward, back function.
The specific use depends on when you need it. For example, when the user registration verification is the background verification, does not meet the requirements of the time can use this, can maximize the user to ensure that less repeated input data.
For example: Load page:
[Code]
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 "Refresh":
OFrame.location.reload ();
}
}
}

To open a JSP page, it must be refreshed with client script.
JavaScript refreshes the page in several ways:
Copy Code code as follows:

1 history.go (0)
2 location.reload ()
3 location=location
4 lo Cation.assign (location)
5 document.execcommand (' Refresh ')
6 window.navigate (location)
7 Location.replace (location)
8 document. Url=location.href
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.