您更喜欢使用哪种方式重新加载当前页面(使用按钮)?
1 <input type="button" value="Reload" onClick="history.go(0)">
2 <input type="button" value="Reload" onClick="location.reload(true)">
3 <input type="button" value="Reload" onClick="window.location.reload(true)">
4 <input type="button" value="Reload" onClick="window.location.href=window.location.href">
5 <input type="button" value="Reload" onClick="document.location.reload(true)">
6 <input type="button" value="Reload" onClick="document.location.href=document.location.href">
由于页面的URL频繁更改,因此AFAIK提供了一个“备用函数”,如
<a href="urlOfCurrentPage.html" onclick="window.location.reload(true);return false;">Reload</a>
对我不起作用,对吧?
发布于 2010-04-13 01:59:24
这取决于你想做什么。第四个和第六个方法不会重新加载任何表单数据,它们本质上是对页面进行单独的访问。有些版本的Firefox在第三种方法上也有问题。除此之外,出于个人喜好,我会选择第五个。这似乎是最清楚的。
https://stackoverflow.com/questions/2624111
复制相似问题