Javascript: The difference between history. Go () and history. Back ()

Source: Internet
Author: User
Javascript: The difference between history. Go () and history. Back ()

<Input type = button value = Refresh onclick ="Window. Location. Reload () ">
<Input type = button value = forward onclick ="Window. History. Go (1)">
<Input type = button value = backward onclick ="Window. History. Go (-1) ">
<Input type = button value = forward onclick ="Window. History. Forward ()">
<Input type = button value = backward onclick ="Window. History. Back () ">

Backward + refresh <input type = button value = backward onclick =" Window. History. Go (-1); window. Location. Reload () "> In C # Web Program For example, return 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 page
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 ();
}
}
}
You must read the book and practice it before you can understand it ~!!!
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.