1.JS实现普通页面刷新
测试页面:
<!DOCTYPE html>
<html>
<head>
<title>页面刷新</title>
</head>
<body>
<h1 id="text">页面刷新</h1>
<button onclick="fresh()">刷新</button>
<script type="text/javascript">
var h1=document.getElementById('text')
function text(){
h1.style.color="red";
h1.innerHTML="我变化了";
}
setInterval(text,1000);
</script>
</body>
</html>
方法一:
function fresh(){
window.location.reload();//强迫浏览器刷新当前页面,默认参数为false,表示从客户端缓存里取当前页。如果指定为true,则以GET方式从服务端取最新的页面,相当于客户端点击F5。
}
方法二:
function fresh(){
history.go(0);
}
方法三: