js调用刷新界面的几种方式
来源:爱站网时间:2020-03-05编辑:网友分享
前端需要显示页面,经常需要刷新才能实现,然而我们程序员要注意哪些操作和细节才能做到呢?别着急,今天爱站技术频道小编带给大家js调用刷新界面的几种方式。
前端需要显示页面,经常需要刷新才能实现,然而我们程序员要注意哪些操作和细节才能做到呢?别着急,今天爱站技术频道小编带给大家js调用刷新界面的几种方式。
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
</head>
<body>
<button onclick="click1()">location.reload();</button>
<button onclick="click2()">history.go(0);</button>
<button onclick="click3()"> location=location ;</button>
<button onclick="click4()">location.assign(location) ;</button>
<button onclick="click5()">location.replace(location) ;</button>
<script>
function click1 () {
//刷新清缓存,相当于Ctrl+F5:location.reload(true)
//普通刷新:location.reload()
location.reload();
}
function click2(){
history.go(0);
}
function click3(){
location=location;
}
function click4(){
location.assign(location) ;
}
function click5(){
location.replace(location)
}
</script>
</body>
</html>
以上就是爱站技术频道小编给大家介绍的js调用刷新界面的几种方式,我们要做到举一反三就能很好的运用所学的知识了。
