如何使用JavaScript刷新页面?
当前回答
您应该使用以下代码
window.location.reload();
其他回答
你可以用两种方式写。第一种是重新加载页面的标准方式,也称为简单刷新
location.reload(); //simple refresh
另一种叫做硬刷新。在这里传递布尔表达式并将其设置为true。这将重新加载页面,销毁旧缓存并从头开始显示内容。
location.reload(true);//hard refresh
在按钮标记中使用onclick=“return location.reload();”。
<button id="refersh-page" name="refersh-page" type="button" onclick="return location.reload();">Refesh Page</button>
问题应该是,
如何使用JavaScript刷新页面
window.location.href = window.location.href; //This is a possibility
window.location.reload(); //Another possiblity
history.go(0); //And another
你被宠坏了。
这对我有用。
function reload(){
location.reload(true);
}
jQueryLoad函数还可以执行页面刷新:
$('body').load('views/file.html', function () {
$(this).fadeIn(5000);
});