![](/img/trans.png)
[英]How to reload a page, when user navigates back to the page from another page in React Native?
[英]Force refresh/reload when user navigates Back and forward again
我想知道当用户按下后退按钮然后再次按下前进时如何确保页面重新加载/刷新。 请帮忙!
您可以使用cookie来设置“按下后退按钮”标志。
例如。 jQuery + jQuery Cookie插件
$(document).ready(function($) {
if ($.cookie("reload") === *YOUR-PAGE-ID*) {
$.removeCookie("reload");
location.reload();
} else if (window.history && window.history.pushState) {
window.history.pushState("forward", null, "./#forward");
$(window).on("popstate", function() {
$.cookie("reload", *YOUR-PAGE-ID*); // set cookie with some page id
});
}
});
由于旧版浏览器不支持popstate
因此您应该使用history.js
<input type='button' onclick="window.location=window.location.href;">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.