在網上找到的幾種返回方式,整理一下貼出來,需要的朋友可以直接使用哦!
js-返回按鈕 返回上一個曆史頁面
連結返回:
<a href="#" onclick="javascript:history.go(-1)">返回</a>
按鈕返回:
<input type="button" name="back" value="返回" onclick="javascript:history.go(-1)">
onClick返回:
onClick="javascript:history.back();return false;"
Firefox,Firefox中必須添加return false;
onclick="javascript:history.go(-1);return false;"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Asp返回按鈕 返回上一個曆史頁面
Asp返回:
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();
禁止緩衝
在我找到的許多方案中,其中有一種建議禁止頁面緩衝。具體是使用伺服器端指令碼,如下所示:
Response.Buffer = True ;
Response.ExpiresAbsolute = Now() - 1;
Response.Expires = 0 ;
Response.CacheControl = "no-cache";
這種方法非常有效!它強制瀏覽器重新訪問伺服器下載頁面,而不是從緩衝讀取頁面。使用這種方法時,編程者的主要任務是建立一個會話級的變數,通過這個變數確定使用者是否仍舊可以查看那個不適合通過後退按鈕訪問的頁面。由於瀏覽器不再緩衝這個頁面,當使用者點擊後退按鈕時瀏覽器將重新下載該頁面,此時程式就可以檢查那個會話變數,看看是否應該允許使用者開啟這個頁面。
例如,假設我們有如下表單:
<%
Response.Buffer = True
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
If Len(Session("FirstTimeToPage")) > 0 then
"使用者已經訪問過當前頁面,現在是再次返回訪問。
"清除會話變數,將使用者重新導向到登入頁面。
Session("FirstTimeToPage") = ""
Response.Redirect "/Bar.asp"
Response.End
End If
"如果程式運行到這裡,說明使用者能夠查看當前頁面
"以下開始建立表單
%>
<form method=post action="SomePage.asp">
<input type=submit>
二: <html>
<head>
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="Cache-Control" CONTENT="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
</head>
三:
<script language="javascript">
<!--
javascript:window.history.forward(1);
//-->
</script>
四:
<A HREF="PageName.htm" onclick="javascript:location.replace(this.href); event.returnvalue=false; ">