tomcat 如何使页面在单击后退按钮时过期?

djmepvbi  于 2022-11-13  发布在  其他
关注(0)|答案(3)|浏览(96)

我已经在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>

通过单击链接“单击我”导航后,我将打开一个新页面。当我单击“后退”按钮时,它正在工作。我希望该页面过期。注意:在两个JSP页面中,我添加了相同的 meta标记。我尝试添加此

<%@ 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和里面的头..仍然我可以看到后面的页面。,测试在Mozilla火狐10. 0和IE8有什么建议?

hmmo2u0o

hmmo2u0o1#

试试这个

<!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>`
w8ntj3qf

w8ntj3qf2#

只要不涉及会话,你就不能通过浏览器的后退按钮使页面过期。它是用于后退浏览页面的,这是许多用户都做的,所以这取决于你希望用户如何浏览你的网站。你实际上需要处理浏览器的后退按钮。有几种方法可以做到这一点。突出的一种是在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">
7vhp5slm

7vhp5slm3#

试试这个

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

相关问题