![](/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.