html – 如何在后退按钮点击过期页面?

前端之家收集整理的这篇文章主要介绍了html – 如何在后退按钮点击过期页面?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我在jsp页面添加了以下元标记
  1. <html>
  2. <head>
  3. <title>xyz</title>
  4. <link type='text/css' rel="stylesheet" href="sdsds/sdsd"/>
  5. <Meta content="max-age=0" http-equiv="cache-control">
  6. <Meta content="no-store" http-equiv="cache-control">
  7. <Meta content="-1" http-equiv="expires">
  8. <Meta content="Tue,01 Jan 1980 1:00:00 GMT" http-equiv="expires">
  9. <Meta content="no-cache" http-equiv="pragma">
  10. </head>
  11. <body><h1>jsdsdsds</h1>
  12. <a href="abc">click me</a>
  13. </body>
  14. </html>

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

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

以上HTML和内部Head ..还有我可以看到后页.,
在mozilla firefox 10.0和IE8中测试过
有什么建议吗?

解决方法

只要不涉及会话,您就无法使浏览器的后退按钮上的页面过期.它可以用于反向浏览许多用户所执行的页面,因此这取决于您希望用户浏览您的站点的方式.你实际上需要处理浏览器的后退按钮.有几种方法可以做到这一点.
突出的一个是在javascript中使用这个代码:`
  1. window.history.forward();

`
但它会将您的后退请求转发到历史记录中的当前页面
对我有用的是:

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

HTML

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

猜你在找的HTML相关文章