如何使用JavaScript刷新页面?
当前回答
您可能需要使用
location.reload()
或可能需要使用
location.reload(forceGet)
forceGet是一个布尔值,也是可选的。
如果您希望强制浏览器从服务器获取页面,以便同时清除缓存,请将此参数设置为true
其他回答
可能最短(12个字符)-使用历史
history.go()
我想有很多方法会奏效:
window.location.reload();history.go(0);window.location.href=window.location.html;
在按钮标记中使用onclick=“return location.reload();”。
<button id="refersh-page" name="refersh-page" type="button" onclick="return location.reload();">Refesh Page</button>
它是JavaScript中最短的。
window.location = '';
这适用于所有浏览器:
location.reload();