在URL上设置时间戳

//获取当前的毫秒数
var timestamp =new Date().getTime();

function ntimestamp() {
    return 't=' + new Date().getTime();
}

//在URL上设置时间戳
function setUrlStamp(url) {
    if(url.indexOf("?") != -1) {
      url = url + "&" + ntimestamp();
    } else {
      url = url + "?" + ntimestamp();
    }
    return url;
}

 调用:

   location.href=setUrlStamp("weightInput.html");

posted @ 2018-03-12 15:38  velin  阅读(3058)  评论(0编辑  收藏  举报