Javascript 如何在 Firefox 中使用 href 刷新页面

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/10961010/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-24 03:47:38  来源:igfitidea点击:

How to refresh page with a href in Firefox

javascriptrefresh

提问by Nick

I am using the following code to refresh my page using a link:

我正在使用以下代码通过链接刷新我的页面:

<a href="javascript:history.go(0)">

This works in Safari (i.e. the page is refreshed to the new content). In Firefox however I am getting the cached page. Is there a way of adapting this to work in all browsers, or do I need a different method?

这在 Safari 中有效(即页面刷新为新内容)。但是在 Firefox 中,我得到了缓存页面。有没有办法使它适用于所有浏览器,还是我需要不同的方法?

Thanks,

谢谢,

Nick

缺口

回答by Pointy

You can use:

您可以使用:

<a href='#' onclick='location.reload(true); return false;'>click me</a>

回答by Nicholas Porter

You can just leave the href as empty and it will reload the current page.

您可以将 href 保留为空,它会重新加载当前页面。

<a href=''>Reload</a>

No need for onclick event or #.

不需要 onclick 事件或 #。