解決方案1:禁用緩存,前一次使用的方法,在電腦上各浏覽器都沒問題,但在ipad、安卓手機上仍有問題
解決方案2:禁用浏覽器後退鍵 Javascript: window.history.forward(1); 結果和方案一一樣的結果,pad上沒效果
解決方案3:Response.Write("<script>window.location.replace('login.ASPx')</script>");仍舊可以後退,感覺還不如1、2,但是在前台加個onclick事件,不涉及表單提交,竟然可以,由此就到方案4
解決方案4:用ajax,在AJax頁面裡將session清空,然後在現在的頁面加JS
function logout(isLogout) {
if (isLogout != "") {
$.AJax({
url: "AJax/logout.ASPx",
data: "code=" + encodeURI(isLogout), cache: false,
datatype: "Html",
success: function (context) {
LogoutReturn(context);
}
});
}
else {
return "Error";
}
}
function LogoutReturn(context) {
if (context == "success") {
location.replace('login.ASPx');
}
}
以上內容是小編給大家介紹的當用戶退出點擊浏覽器後退仍可回到原來頁面的解決方案,希望對大家有所幫助!