首次进入页面的时候用js刷新页面

时间:2023-03-09 14:34:25
首次进入页面的时候用js刷新页面
    window.onload = function(){
var url=document.location.href; //获取浏览器访问栏里的地址
if( url.indexOf("times=")==-1 ){ //判断地址后面是否多了某些值,没有就进方法里进行刷新
var times = new Date();
if( url.indexOf("?")==-1 ){
window.location.href = url+"?times="+times.getTime();
}else{
window.location.href = url+"&times="+times.getTime();
}
}
}