![](/img/trans.png)
[英]How to minimize and maximize internet explorer in ASP.NET and JAVASCRIPT?
[英]How to disable the Backspace button in Internet explorer using asp.net
當前,當我注銷后按退格按鈕,然后打開上一頁,而不是將其重定向到登錄頁面,我在注銷頁面的頁面加載中使用了服務器端代碼,它適用於firefox,opera和chrome,但適用於IE和Safari工作不正常。
這是我的注銷頁面頁面加載中的代碼
protected void Page_Load(object sender, EventArgs e)
{
Session.Abandon();
Session.Clear();
Session.RemoveAll();
HttpCookie cookie = new HttpCookie("UserInfo");
cookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(cookie);
Response.Redirect("Default.aspx", false);
Response.Cache.SetExpires(DateTime.UtcNow.AddMinutes(-1));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetNoStore();
}
您對此建議在IE和Safari上都能使用的建議是什么?
我認為即使禁用后退按鈕,用戶也可以通過按“ Alt +箭頭按鈕”或“退格鍵”返回。 在瀏覽器中無法禁用后退按鈕。
第1步。
在頁面加載中添加以下javascript代碼
<script>
function callme()
{
history.go(1);
}
</script>
第2步。
不允許將頁面保存在緩存中。 在 <head>部分之間添加以下行
<meta http-equiv="Expires" CONTENT="0">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="Pragma" CONTENT="no-cache">
第三步
單擊注銷。 從瀏覽器中清除歷史記錄,然后從服務器端重定向到“登錄”頁面。
string strScript = "<script>var Backlen=history.length;history.go(-Backlen);window.location.replace('Login.aspx');</script>";
ClientScript.RegisterClientScriptBlock(this.GetType(), "ClearHistory", strScript);
編輯:
在母版頁或任何aspx頁的主體標簽中
添加此標簽
<body onpageshow="if (event.persisted) noBack();">
在Java腳本中
<script type="text/javascript" language="javascript">
window.onload = function () {
noBack();
}
window.history.forward();
function noBack() {
window.history.forward();
}
</script>
絕對不允許用戶轉到上一頁
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.