如何使用JavaScript刷新页面?


当前回答

你们可能需要使用

    location.reload(forceGet)

forceGet是一个布尔值,也是可选的。

默认值为false,这将重新加载缓存的页面。

其他回答

$(document).on("click", "#refresh_btn", function(event) 
{
     window.location.replace(window.location.href);
});

它是JavaScript中最短的。

window.location = '';

你可以用两种方式写。第一种是重新加载页面的标准方式,也称为简单刷新

location.reload(); //simple refresh

另一种叫做硬刷新。在这里传递布尔表达式并将其设置为true。这将重新加载页面,销毁旧缓存并从头开始显示内容。

location.reload(true);//hard refresh

你们可能需要使用

    location.reload(forceGet)

forceGet是一个布尔值,也是可选的。

默认值为false,这将重新加载缓存的页面。

<i id="refresh" class="fa fa-refresh" aria-hidden="true"></i>

<script>
$(document).on('click','#refresh',function(){
   location.reload(true);
});
</script>