如何使用JavaScript刷新页面?
当前回答
我找到了
window.location.href = "";
or
window.location.href = null;
还进行页面刷新。
这使得移除任何哈希值后重新加载页面变得非常容易。当我在iOS模拟器中使用AngularJS时,这非常好,因此我不必重新运行应用程序。
其他回答
你们可能需要使用
location.reload(forceGet)
forceGet是一个布尔值,也是可选的。
默认值为false,这将重新加载缓存的页面。
问题应该是,
如何使用JavaScript刷新页面
window.location.href = window.location.href; //This is a possibility
window.location.reload(); //Another possiblity
history.go(0); //And another
你被宠坏了。
jQueryLoad函数还可以执行页面刷新:
$('body').load('views/file.html', function () {
$(this).fadeIn(5000);
});
这适用于所有浏览器:
location.reload();
use
location.reload();
or
window.location.reload();