如何使用JavaScript刷新页面?
当前回答
它是JavaScript中最短的。
window.location = '';
其他回答
简单的Javascript解决方案:
location = location;
<buttonClick=“location=location;”>重新加载</button>
jQueryLoad函数还可以执行页面刷新:
$('body').load('views/file.html', function () {
$(this).fadeIn(5000);
});
window.location.reload()将从服务器重新加载,并将再次加载所有数据、脚本、图像等。
因此,如果您只想刷新HTML,window.location=document.URL将返回得更快,流量更少。但如果URL中有散列(#),则不会重新加载页面。
<i id="refresh" class="fa fa-refresh" aria-hidden="true"></i>
<script>
$(document).on('click','#refresh',function(){
location.reload(true);
});
</script>
问题应该是,
如何使用JavaScript刷新页面
window.location.href = window.location.href; //This is a possibility
window.location.reload(); //Another possiblity
history.go(0); //And another
你被宠坏了。