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 ~!!!