Disable the back button of the browser

Source: Internet
Author: User
The browser's back button makes it easy for us to return to previously accessed pages, which is undoubtedly very useful. But sometimes we have to disable this function to prevent users from disrupting the order of page access. This article describes various methods for disabling the browser's back button on the Internet, and analyzes their advantages and disadvantages and applicable scenarios.
I. Overview
Many people once asked, "How can we 'deactivate 'the browser's back button ?", Or "how can we prevent users from clicking the back button to return to previously browsed pages ?" I visited many websites and referred to various implementation methods described by these websites. If you frequently access ASP Programming websites, you may have seen some of the content introduced in this article. The task in this article is to introduce all possible methods and find the best method!
II. 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.

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.