直接上代码
var Url=window.location.href;
function timestamp(url){
// var getTimestamp=Math.random();
var getTimestamp=new Date().getTime();
if(url.indexOf("?")>-1){
url=url.substr(0,url.indexOf("?"))+"?timestamp="+getTimestamp
}else{
url=url+"?timestamp="+getTimestamp
}
return url;
}
//网页URL添加时间戳
//window.history.pushState 不刷新页面,但是改变页面的url地址
window.history.pushState({},0,timestamp(Url));
console.log(window.location.href);