The difference between javascript:history.go () and History.back () (reproduced)

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Transferred from: http://www.mikebai.com/Article/2009-11/757.html

<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 value= back onclick= " Window.history.go ( -1); Window.location.reload () "> in C # Web programs, such as Page button write back to the previous page of code

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

Wherein, HISTORY.GO (-2), to write as-2, because the button event triggered before the page has been refreshed once, so should be-2.

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

It is also written here as "-2". It's different from direct script writing. History.back () is a previous page
I=1
History.go (i) go to the specified page
If it is history.go (0) that is to refresh these two belong to the JS code, the equivalent of IE forward, backward function.
The specific use depends on when you need this. For example, the user registration verification is the background verification, do not meet the requirements of the time you can use this, can maximize the user to ensure less repetitive input data.
For example: Loading 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 "Refresh":
OFrame.location.reload ();
}
}
}


Opens a JSP page, which must have been refreshed with client script.
JavaScript refreshes the page in several ways:
1 history.go (0)
2 location.reload ()
3 location=location
4 location.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.