Jsp page Jump

Source: Internet
Author: User

Window. history. back (-1)

window.history.back();window.history.forward()window.history.go(-1)
 
Javascript: history. go (-1) and javascript: history. back (-1)

Go (-1): return to the previous page. The content in the original page form will be lost. back (-1): return to the previous page. The content in the original page form will be retained.

Go (-1): return to the previous page. The content in the original page form will be lost. back (-1): return to the previous page. The content in the original page form will be retained.

<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 ()">
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 ();
}
}
}
 
 
If the button ID is LinkButton1 

Protected void Page_Load (object sender, EventArgs e)
{
Int x = 0;
If (ViewState ["x"]! = Null)
{
X = (int) ViewState ["x"];
}
X ++;
ViewState ["x"] = x;

This. LinkButton1.Attributes. Add ("onclick", "window. history. go (-" + x + "; return false ");
}

Public static int GetPageRequestTimes ()
{
String sKey = System. Web. HttpContext. Current. Request. Url. LocalPath;
HttpCookie cookfrom = System. Web. HttpContext. Current. Response. Cookies [sKey];
String sTimes = cookfrom ["count"];
If (CCConvert. IsInt32 (sTimes) return Convert. ToInt32 (sTimes) + 1;
Else return 0;
}

Public static void SetBtnBackJs (System. Web. UI. HtmlControls. HtmlInputButton btn)
{
Int iTimes = (GetPageRequestTimes () *-1;
Btn. Attributes. Add ("onclick", "javascript: window. history. go (" + iTimes. ToString () + ");");
}
Public static void SavePageBackInfo (System. Web. UI. Page)
{
String sKey = page. Request. Url. LocalPath;
HttpCookie cookfrom = page. Request. Cookies [sKey];
If (cookfrom = null)
{
Cookfrom = new HttpCookie (sKey );
}
String sTimes = "0 ";
If (page. IsPostBack)
{
STimes = cookfrom ["count"];
STimes = (Convert. ToInt32 (sTimes) + 1). ToString ();
}
Cookfrom ["count"] = sTimes;
Page. Response. Cookies. Add (cookfrom );

}

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.