SoFunction
Updated on 2025-04-11

Next, use js to return to the previous page implementation method set

Method 1:
In the source code in aspx
<input type="button onclick="javascript:(-1);"value="Return to previous page">
Brief analysis: This is done using HTML control, and through an onclick event, a method in JavaScript is called. This is the simplest, and it also applies to static pages, ASP pages, etc.
Method 2:
use
If you have a certain understanding of ASP, you will be familiar with this thing. The first method is to directly implement it in an HTML page, and this is implemented in a background environment (this statement doesn't seem to be very standardized, haha)
Copy the codeThe code is as follows:

("<script language=javascript>(-2);</script>)
<a href="#" onclick="javascript:();">Return to the previous page</a>

Is it necessary to use a value of -2? I personally think it is like this: because in the page, when you press a button, the page will be implemented in the page, in fact, the page is refreshed twice, and what we want is the first time, so...

Method 3
Using () or ()

Add in page_load
if(!IsPostBack)
ViewState["retu"]=();
In the return button event
(ViewState["retu"].ToString());
or (ViewState["retu"].ToString());

Brief analysis:
You can obtain information about the URL requested by the client last time. It is best to make a judgment on it when using this.
if(ViewState["UrlReferrer"]!=null)
(ViewState["UrlReferrer"].ToString();
else
{
("Sorry, the current page number");

This will make a little better
}
Also note when using:
1. If the previous page uses the method to navigate to the current page, return an empty value
2. If there are two pages A and B, and page A is directly requested in the browser and navigate to page B in the Page_Load event of page A, then return empty. Because the page has not been initialized in the Page_load event, the information on the current page cannot be recorded, and if you navigate to page b, you cannot obtain the information on the previous page.
3. Clicking the refresh button will not change

Method 4:
This method is probably rarely used by people, but I tried it and it was pretty good.
Enter in the button's onClick event
("e", "<script language=javascript>(-2);</script>");
You can also return to the previous page

Method 5
Copy the codeThe code is as follows:

<a href=<%=("http_Referre)%>
<asp:image visible = true" imagine="previous page" runat="server"/></a>

Method 6
Copy the codeThe code is as follows:

("<script>alert('prompt message');()</script>");
("<script>alert('prompt message');='" + PageURL + "'</script>")
("<script>alert('prompt message');='" + PageURL + "'</script>");
("<script>alert('prompt message');=;</script>");

Here I will talk about the little difference between using Javascript and using(). If you want to keep the data you filled in when using the day form, you need to use(); this thing, if you just return directly without doing any operations, you can use().