gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 02:01:04 25 4
gpt4 key购买 nike

我在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 页面中,我都添加了相同的元标记。我试着添加这个

<%@ 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 内部..我仍然可以看到后页.,在 mozilla firefox 10.0 和 IE8 中测试有什么建议吗?

最佳答案

试试这个

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

关于html - 如何在单击后退按钮时使页面过期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13914844/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com