![](/img/trans.png)
[英]Is there a way using jQuery or Javascript to force a page to open in Firefox?
[英]Force a page refresh using Javascript in Firefox
我有一个简单的请求,使用下面的Javascript代码刷新页面:
function tb_closeRefresh() {
window.location.reload(true);
}
这在IE中运行良好,但Firefox只获取缓存版本,需要用户按F5才能获得最新版本的页面。
我添加了元标记:
<meta http-equiv="Pragma" content="no-cache">
但这没有用。
有任何想法吗???
您可以调用相同的页面,但通过更改查询字符串让它看起来像是另一个页面:
window.location.href = "index.html" + "?" + Date.parse(new Date());
这适用于每个浏览器。 您可以通过从location.href
提取当前页面来改进它。
编辑:
如果你已经有一个现有的查询字符串,你必须使用&
insead ?
:
window.location.href = "product.aspx?id=prod" + "&" + Date.parse(new Date());
如果要刷新,可以将window.location
重置为window.location
。
window.location = window.location
分配window.location
将执行重定向,并且由于window.location
返回当前位置,因此上述语句将充当重定向。
尝试
function page_reload()
{
window.location = 'http://domain.com/page.php';
}
要么
<a href="javascript:history.go(0);">Click here to refresh the page</a>
我不认为Firefox支持重载,你应该使用:
var myUrl = window.location;
window.location.replace(myUrl)
我发现这适用于IE,Apple Safari和Firefox。 它似乎不适用于Mac上的Firefox。
也许这些会起作用?:
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache-control" content="no-store">
您可以使用下面的代码来解决您的问题
window.location.href = window.location.href + '?refresh';
但是你需要使用“Pushstate”来更新url,请查看更多详细信息window.history.pushState刷新浏览器
文件说使用:
window.location.reload(true);
https://developer.mozilla.org/en-US/docs/Web/API/Location/reload
它应该适用于包括移动设备在内的所有浏
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.