问题描述
在点击导航器返回按钮时,是否有跨浏览器兼容的强制刷新页面的方式?
我试图访问实际的Cookie:
我有一个js setcookie函数记录类型选择器中的更改
$ #type-select).change(function(){
var type = $(#type-select)。val();
SetCookie(liste-voyage-type );
});
我想在此网页上返回时检索该值,点击浏览器返回按钮php
if(isset($ _ COOKIE [liste-voyage-type]))
$ type = $ _COOKIE [liste-voyage-type];
您可以这样做:
例如,假设有两页:page1和page2
在 Page1 中执行以下操作:
< script&
if(sessionStorage.getItem(Page2Visited)){
sessionStorage.removeItem(Page2Visited);
window.location.reload(true); // force refresh page1
}
< / script>
并在 page2 :
< script>
sessionStorage.setItem(Page2Visited,True);
< / script>
现在,每当您单击第2页上的返回按钮时, p>
Is there a cross-browser compatible way of forcing page refresh when clicking the navigator back button?
i am trying to access to actualised cookies :
i have a js setcookie function that record changes in a type selector
$( "#type-select" ).change(function() {
var type = $("#type-select").val();
SetCookie("liste-voyage-type",type);
});
i'd like to retrieve that value when returning on this page, clicking the browser back button, using php
if (isset($_COOKIE["liste-voyage-type"]))
$type=$_COOKIE["liste-voyage-type"];
I had a similar requirement in my project. You can do something like this:
For example, lets say there are two pages: page1 and page2
In Page1 do something like this:
<script>
if (sessionStorage.getItem("Page2Visited")) {
sessionStorage.removeItem("Page2Visited");
window.location.reload(true); // force refresh page1
}
</script>
And in page2:
<script>
sessionStorage.setItem("Page2Visited", "True");
</script>
Now, it will force a page refresh on page1, whenever you click back button from page2.
这篇关于如何强制页面刷新浏览器上的点击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!