如何刷新后退按钮点击页面? [英] How to refresh page on back button click?

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

问题描述

我用的.htaccess路由所有的流量到一个单一的index.php文件。下面的code指挥交通,但由于某些原因,它不与后退按钮的工作。我不知道该怎么做才能让后退按钮的工作。我已经尝试了各种东西,一派挺了一下,没有它一直所以我希望这里有人能帮助!

I use .htaccess to route all of my traffic to a single index.php file. The code below to directs traffic, but for some reason it doesn't work with the back button. I don't know what to do to get the back button working. I've tried a variety of things and googled quite a bit and none of it has worked so I'm hoping someone here can help!

<?php
   if(isset($_GET['parameters'])) {
      if($_GET['parameters'] == "repair")
         include 'repair.html';
      else if($_GET['parameters'] == "training")
         include 'training.html';
      else if($_GET['parameters'] == "products")
         include 'products.html';
      else if($_GET['parameters'] == "about")
         include 'about.html';
      else if($_GET['parameters'] == "employees")
         include 'employees.html';
      else if($_GET['parameters'] == "training")
         include 'training.html';
      else if($_GET['parameters'] == "newaccount")
         include 'newaccount.html';
      else if($_GET['parameters'] == "contact")
         include 'contact.html';
      else if($_GET['parameters'] == "recommended")
         include 'recommended.html';
      else if($_GET['parameters'] == "careers")
         include 'careers.html';
      else
         include 'home.html';
   }
   else
      include 'home.html';
?>

到目前为止,我已经尝试和失败使用方法: window.onbeforeunload 身体onunload =

目前已经得到了一个方法来 onunload = location.reload()什么的!不知怎的,必须知道语法!!

There has got to be a way to onunload=location.reload() or something! Somehow has to know the syntax!!

推荐答案

试试这个......没有经过测试。我希望它会为你工作。

Try this... not tested. I hope it will work for you.

请一个新的PHP文件。您可以使用页面上的前进和后退按钮和数字/时间戳始终更新。

Make a new php file. You can use the back and forward buttons and the number/timestamp on the page always updates.

<?php
header("Cache-Control: no-store, must-revalidate, max-age=0");
header("Pragma: no-cache");
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
echo time();
?>
<a href="http://google.com">aaaaaaaaaaaaa</a>

找到另外的解决方案

当用户点击返回按钮onload事件应该被解雇。通过JavaScript不能创建的元素将保留它们的值。我建议保持在一个INPUT TYPE =隐藏设置为显示在动态创建的元素中使用的数据备份:没有那么的onload使用输入的值来重建动态元素,以他们的方式

The onload event should be fired when the user hits the back button. Elements not created via JavaScript will retain their values. I suggest keeping a backup of the data used in dynamically created element within an INPUT TYPE="hidden" set to display:none then onload using the value of the input to rebuild the dynamic elements to the way they were.

<input type="hidden" id="refreshed" value="no">
<script type="text/javascript">
onload=function(){
var e=document.getElementById("refreshed");
if(e.value=="no")e.value="yes";
else{e.value="no";location.reload();}
}

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

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