# js代码实现页面加载后刷新一次

*Published:* 2023-11-16
*Author:* 客服001

#### 温馨提醒

如果文章内容或图片资源失效，请留言反馈，我们会及时处理，谢谢

本文最后更新于2023年11月16日，已超过 180天没有更新



```
<script>
  
String.prototype.queryString = function(name) {
var reg = new RegExp("[?&]" + name + "=([^&]+)", "i"),
    r = this.match(reg);
    return r !== null ? unescape(r[1]) : null
};
window.onload = function() {
    var last = location.href.queryString("_v");
    if (location.href.indexOf("?") == -1) {
        location.href = location.href + "?_v=" + (new Date().getTime())
    } else {
        var now = new Date().getTime();
        if (!last) {
            location.href = location.href + "&_v=" + (new Date().getTime())
        } else if (parseInt(last) < (now - 500)) {
            location.href = location.href.replace("_v=" + last, "_v=" + (new Date().getTime()))
        }
    }
};
  
</script>
```