1.
Copy CodeThe code is as follows: <script language= "JavaScript" > Javascript:window.history.forward (1); </script>
Using JS to generate a "forward" action to counteract the fallback function, this method should be the most concise, and do not need to consider the user two or more times "back" situation, the disadvantage is that when the user has disabled JavaScript is invalidated.
2.
Copy CodeThe code is as follows: <a href= "logout.do" onclick= "Javascript:location.replace (THIS.HREF); Event.returnvalue=false; "> Logout (back Disabled) </A>
Use Location.replace to go from one page to another page. The principle of this approach is to replace the current history with the URL of the new page so that there is only one page in the browsing history, and the Back button never becomes available. I think this may be the way many people seek, but it's still not the best way to do it in any situation. The downside to this approach is that simply using Response.Redirect will no longer work, because every time a user goes from one page to another, we have to clear location.history with the client code. Also note that this method clears the last access history, not the entire access record.
3.
When the keyboard knocks down the Back button (Backspace) 1, the browser is forbidden to automatically back 2, but does not affect the password, single-line text, multi-line text input box and other fallback operations
Copy CodeThe code is as follows: <script type= "Text/javascript" >
Handle keyboard events prohibit back key (Backspace) password or single line, multiline text box except function Banbackspace (e) {var ev = e | | window.event;//get Event object var obj = Ev.targe T | | ev.srcelement;//Getting event sources
var t = Obj.type | | Obj.getattribute (' type ');//Get Event Source Type
Gets the event type as the judging condition var vreadonly = obj.getattribute (' readonly '); var venabled = Obj.getattribute (' enabled '); Handling Null values Case vreadonly = (vreadonly = = null)? False:vreadonly; venabled = (venabled = = null)? true:venabled;
When the BACKSPACE key is hit, the event source type is password or single line, multiline text,//And the ReadOnly property is True or the Enabled property is False, the BACKSPACE key is invalidated var flag1= (Ev.keycode = = 8 && (t== "Password" | | t== "TEXT" | | t== "TEXTAREA") && (Vreadonly==true | | venabled!=true))? True:false;
When the BACKSPACE key is hit, the event source type is non-password or single-line, multiline text, the BACKSPACE key fails var flag2= (Ev.keycode = = 8 && t! = "password" && t! = "text" & ;& t! = "textarea")? True:false;
Determine if (Flag2) {return false;} if (Flag1) {return false;}}
No back key action in Firefox, Opera Document.onkeypress=banbackspace; No back key action on IE, Chrome document.onkeydown=banbackspace;
</script>
All of the above methods are responses to the back button, and the client browser needs to open the JavaScript code.
4. Disable caching
Copy CodeThe code is as follows: <%
Response.setheader ("Cache-control", "No-cache");
Response.setheader ("Cache-control", "No-store");
Response.setdateheader ("Expires", 0);
Response.setheader ("Pragma", "No-cache"); %>
This method uses a server-side script that forces the browser to revisit the server download page without reading from the cache, combining the <logic> tags in the Struts JSP page for redirection.
All of the above methods have certain limitations
5.
Copy CodeThe code is as follows: <script language= "JavaScript" >
function logout () {
Window.close (TRUE);
window.open ("logout.do");
} </script> <button onclick= "logout ()" >Logout</button>
This method is more lazy, turn off the browser and re-open, after my test in the visual almost do not feel the delay, while ensuring that the back button is not available (the new Window browser Back button is gray), it seems to be a good method, but the shortcomings are more obvious:
First, the size of the browser window that is closed and re-opened may be different, and the user can clearly see this process and, to some extent, affect the operation.
Second, ibid, this is a JavaScript method.
JavaScript How to disable the browser back button