如何到期后退按钮点击页面?(How to expire page on back button cl

2019-07-05 13:55发布

我加入以下在jsp页面meta标签

<html>
<head>
<title>xyz</title>
<link type='text/css' rel="stylesheet" href="sdsds/sdsd"/>
<meta content="max-age=0" http-equiv="cache-control">
<meta content="no-store" http-equiv="cache-control">
<meta content="-1" http-equiv="expires">
<meta content="Tue, 01 Jan 1980 1:00:00 GMT" http-equiv="expires">
<meta content="no-cache" http-equiv="pragma">
</head>
<body><h1>jsdsdsds</h1>
<a href="abc">click me</a>
</body>
</html>

通过点击链接导航后“点击我”我打开了新的一页。 当我点击后退按钮是working..I想要的页面过期。注:在这两个jsp页面我添加了相同的元标记。 我尝试添加该

<%@ page import="java.lang.*" %>
<%
// Set to expire far in the past.
response.setHeader("Expires", "Sat, 6 May 1971 12:00:00 GMT");
// Set standard HTTP/1.1 no-cache headers.
response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
// Set IE extended HTTP/1.1 no-cache headers (use addHeader).
response.addHeader("Cache-Control", "post-check=0, pre-check=0");
// Set standard HTTP/1.0 no-cache header.
response.setHeader("Pragma", "no-cache");
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

上述两种HTML和内部Head..still我可以看到背页,测试在Mozilla Firefox 10.0和IE8什么建议吗?

Answer 1:

你不能只要到期浏览器的后退按钮页面作为会话不是involved.Its那里的许多用户做的网页浏览回来,所以这要看你怎么想用户浏览您的网站。 实际上,你需要处理浏览器的后退按钮。 有几个方式做到这一点。 突出的一个是在JavaScript中使用此代码:`

window.history.forward();

`但它会将您的回请求当前页面的历史,对我来说是工作的一个:

<script type="text/javascript">
function noBack(){
            location.replace(logouturl);
            window.location="logouturl";
}

HTML

<input type="button" value="SignOut" onclick="noBack()" align="middle">


Answer 2:

试试这个

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
   <html xmlns="http://www.w3.org/1999/xhtml" >
  <title>Untitled Page</title>
  <script type = "text/javascript" >
  function changeHashOnLoad() {
 window.location.href += "#";
 setTimeout("changeHashAgain()", "50"); 
 }

function changeHashAgain() {
window.location.href += "1";
}

var storedHash = window.location.hash;
 window.setInterval(function () {
 if (window.location.hash != storedHash) {
     window.location.hash = storedHash;
}
}, 50);


</script>
 </head>
 <body onload="changeHashOnLoad(); ">
  Try to hit back!
 </body>
 </html>`


Answer 3:

试试这个

 <META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
 <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
 <META HTTP-EQUIV="EXPIRES" CONTENT="0">

检查此链接可能对你有帮助...



文章来源: How to expire page on back button click?