JS, ASP return button, return connection code

Source: Internet
Author: User

I have found several return methods on the Internet and posted them. You can use them directly!
JS-return button returns the previous history page

Link return:
<A href = "#" onclick = "javascript: history. Go (-1)"> return </a>

Button return:

<Input type = "button" name = "back" value = "return" onclick = "javascript: history. Go (-1)">

Onclick returns:

Onclick = "javascript: history. Back (); Return false ;"

Firefox must add return false;

Onclick = "javascript: history. Go (-1); Return false ;"

Certificate ------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Asp return button returns the previous history page

ASP returns:

Response. cache. setcacheability (httpcacheability. nocache );

Response. expires =-1;

Response. addheader ("Pragma", "No-Cache ");

Response. addheader ("cache-control", "No-Cache ");

Response. cachecontrol = "no-Cache ";

Response. cache. setnostore ();

 

Disable caching

Among the many solutions I have found, it is recommended to disable page caching. Specifically, the server script is used as follows:

Response. Buffer = true;

Response. expiresabsolute = now ()-1;

Response. expires = 0;

Response. cachecontrol = "no-Cache ";

This method is very effective! It forces the browser to re-access the server download page instead of reading the page from the cache. When using this method, the programmer's main task is to create a session-level variable, using this variable to determine whether the user can still view the page that is not suitable for access through the back button. Because the browser no longer caches this page, when the user clicks the back button, the browser will re-download the page, then the program can check the session variable to see whether the user should be allowed to open this page.

For example, suppose we have the following form:

<%

Response. Buffer = true

Response. expiresabsolute = now ()-1

Response. expires = 0

Response. cachecontrol = "no-Cache"

If Len (Session ("firsttimetopage")> 0 then

"The user has accessed the current page and now returns access again.

"Clear session variables and redirect users to the logon page.

Session ("firsttimetopage") = ""

Response. Redirect "/bar. asp"

Response. End

End if

"If the program runs here, you can view the current page.

"Create a form as follows

%>

<Form method = post action = "somepage. asp">

<Input type = submit>

Ii. <HTML>

<Head>

<Meta http-equiv = "expires" content = "0">

<Meta http-equiv = "cache-control" content = "no-Cache">

<Meta http-equiv = "Pragma" content = "no-Cache">

</Head>

III:

<Script language = "JavaScript">

<! --

Javascript: window. History. forward (1 );

// -->

</SCRIPT>

IV:

<A href = "pagename.htm" onclick = "javascript: location. Replace (this. href); event. returnvalue = false;">

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.