如何过期返回按钮点击页面? [英] How to expire page on back button click?

查看:137
本文介绍了如何过期返回按钮点击页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jsp页面中添加了以下元标记:

 < html> 
< head>
< title> xyz< / title>
< link type ='text / css'rel =stylesheethref =sdsds / sdsd/>
< meta content =max-age = 0http-equiv =cache-control>
< meta content =no-storehttp-equiv =cache-control>
< meta content = - 1http-equiv =expires>
< meta content =no-cachehttp-equiv =pragma>
< / head>
< body>< h1> jsdsdsds< / h1>
< a href =abc>按一下< / a>
< / body>
< / html>

点击click me链接后,我打开一个新页面。当我点击返回按钮,它正在工作..我希望页面过期..
注意:在这两个jsp页面我已经添加了相同的元标记。
我试着添加这个

 <%@ page import =java.lang。*%> 
<%
//设置为在过去时过期。
response.setHeader(Expires,Sat,1971 5月6日12:00:00 GMT);
//设置标准的HTTP / 1.1无缓存头。
response.setHeader(Cache-Control,no-store,no-cache,must-revalidate);
//设置IE扩展HTTP / 1.1无缓存头(使用addHeader)。
response.addHeader(Cache-Control,post-check = 0,pre-check = 0);
//设置标准的HTTP / 1.0无缓存头。
response.setHeader(Pragma,no-cache);
response.setDateHeader(Expires,0); //防止在代理服务器缓存
%>

同时在HTML和里面Head..still我可以看回页面,
测试在Mozilla Firefox 10.0和IE8
的任何建议吗?

解决方案

因为会话不涉及。它可以用来浏览很多用户所做的页面,所以这取决于用户如何浏览你的网站。你实际上需要处理浏览器的后退按钮。有几种方法可以做到这一点。
在JavaScript中使用这个代码是一个很好的例子:``````````````````

`
但是它会将您的回复请求转发到历史记录中的当前页面
我为之工作的是:

 < script type =text / javascript> 
函数noBack(){
location.replace(logouturl);
window.location =logouturl;

$ / code>

HTML

 < input type =buttonvalue =SignOutonclick =noBack()align =middle> 


I have added following meta tag in jsp page

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

After navigating by clicking link "click me" I am opening a new page. When I click back button it is working..I want the page to expire.. Note:In both jsp page I have added same meta tag. I tried adding this

<%@ 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
%>

both above HTML and inside Head..still I can see back page., Tested in mozilla firefox 10.0 and IE8 Any suggestion?

解决方案

You cannot expire a page on back button of browser as long as sessions aren't involved.Its there for back browsing of pages which many users do, so it depends on how you want user to browse your site. You actually need to handle the back button of browser. There are few ways to do it. Prominent one is using this code in javascript:`

window.history.forward();

` but it will forward your back request to current page in history The one that worked for me is:

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

HTML

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

这篇关于如何过期返回按钮点击页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆