![](/img/trans.png)
[英]When clicking a button go to next page and refresh the previous one Jquery Mobile
[英]Go To Previous Page and Refresh - both in one button using javascript/Jquery
有没有办法创建一个按钮,点击后会转到上一页,然后立即刷新页面? 我使用以下代码返回上一页但它没有重新加载/刷新..
<input type="button" value="Back" onClick="javascript: history.go(-1)">
谢谢 :)
刷新加载页面的唯一方法是在新页面中使用window.location.reload()
。
您可以尝试使用document.referrer
获取最后一个URL(或者将其页面视图的历史记录保存在cookie中),然后在哈希中添加一些内容,使其像:
HTTP://stackoverflow.com#didGoBack
然后,在javascript中,使用window.location.hash
检查是否存在该哈希,如果是,则重新加载页面。 注意。 除非他们通过链接到达该页面,否则不会设置推荐人。
我想我发明了这样做的方法。 通过向url添加随机参数,我们强制浏览器刷新...
var backLocation = document.referrer;
if (backLocation) {
if (backLocation.indexOf("?") > -1) {
backLocation += "&randomParam=" + new Date().getTime();
} else {
backLocation += "?randomParam=" + new Date().getTime();
}
window.location.assign(backLocation);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.