Assume that we have such an operation procedure.
1.we have two pages, one showing the show.html page and one adding the information page add.html
2.when you click "add information" in show.html, the "add.html" page is displayed.
3.there is a return button in add.html, and of course there is a submit button
4. The page is refreshed every time you click Submit.
Problem:
After clicking "n ., I will return the sample to show.html,
Of course, response.redirect(?sho=html ") cannot be used in the server ").
Implemented using JavaScript
Code
// Write the following JS script in add.html
< Script Language = " Javascript " Type = " Text/JavaScript " >
// Click Submit to execute
Function Add_btn_accept_click ()
{
Location. href=_ Fun_getnexturlstring ();
}
// Click return to execute
Function Add_btn_back_click ()
{
If (Location. Hash = "" )
{
History. Go (-1);
} Else
{
VaR_ Hashnum=Parseint (location. Hash. substring (1),10);
History. Go (_ hashnum );
}
}
// Here is a self-written URL method.
Function _ Fun_getnexturlstring ()
{
// Define a new URL variable
VaR _ Newurl = "" ;
// Get path
VaR _ Pathname = Location. pathname;
// Get Parameters
VaR _ Search = Location. search;
// Add a random data to the parameter to ensure that every page loaded is refreshed.
VaR _ Randindexof = _ Search. indexof ( " & Rand = " );
VaR _ Addurl = " & Rand = " + Math. Random ();
If (_ Randindexof ! = - 1 )
{
_ Search=_ Search. substring (0, _ Randindexof );
}
// Here is the most important,
// Adds an anchor to the URL.
// The value of. Anchor is reduced by 1 every time.
// Then you will know how many times you submitted
If (Location. Hash = "" )
{
_ Newurl=_ Pathname+_ Search+_ Addurl+"#-2";
} Else
{
VaR _ Nexthash = Parseint (location. Hash. substring ( 1 ), 10 ) - 1 ;
VaR _ Hash = " # " + _ Nexthash;
_ Newurl = _ Pathname + _ Search + _ Addurl + _ Hash;
}
// Return custom URL
Return _ Newurl;
}
< / SCRIPT>
For example, your address is
Http://liuju150.cacacoo.com/add.html
When you have not submitted the job, click "back.
Add_btn_back_click ()
In this example, check whether your hash value (#12) is followed by your URL)
So you will know that you opened it for the first time, so you will directly return to the previous page.
You submit each time.
URL
Http://liuju150.cacacoo.com/add.html? Rand = 0.12432 #-2
Http://liuju150.cacacoo.com/add.html? Rand = 0.12432 #-3
Http://liuju150.cacacoo.com/add.html? Rand = 0.12432 #-4
Add the following number.
When you arrive n times.
Http://liuju150.cacacoo.com/add.html? Rand = 0.12432 #-n
You only need to know the N value, and you can notify the browser of the first number of records you want to return.
Sometimes, response.redirect(?sho=html ").
But when I was working on a project, this was the case.
A user control is created, which requires a return button.
You don't know where to return this response
Here
Http://www.cnblogs.com/liuju150/archive/2009/09/11/1564994.html
Here is the effect
Http://liuju150.cacacoo.com/
Now there is only one submit button for adding a page
If I add a response, this may be used.
It seems that there is another way to record cookies on the Internet.
No research support yet