JS自动刷新页面一次

1
2
3
4
5
6
7
8
<script type="text/javascript">  
//刷新页面
if(location.href.indexOf("refresh=1") === -1) {
setTimeout(function() {
location = location.href + "?refresh=1"
},1)
}
</script>

或者

1
2
3
4
5
6
7
8
9
10
<script type="text/javascript">  
//刷新页面
function refreshOnce(){
if (location.href.indexOf("?xyz=") < 0) {
location.href = location.href + "?xyz=" + Math.random();
}
}
</script>

<body onload="refreshOnce()">