How do I Attach or update a timestamp querystring parameter

后端 未结 2 1261
春和景丽
春和景丽 2021-01-17 05:16

I want to attach a timestamp to my querystring in order to ensure that the browser bypasses its cache when I refresh the page via javascript. I need to account for an exist

相关标签:
2条回答
  • 2021-01-17 05:42

    For manipulating the query string parameters I recommend you this plugin:

    • query-object

    It's very easy to use:

    var timestamp = $.query.get('ts'); // get a value
    
    window.location = $.query.set('ts', newValue); // set a value and navigate
    
    0 讨论(0)
  • 2021-01-17 05:54
    var newLocation = window.location.href.replace(/\?.*(ts=\d*)/, "ts=" + new Date().valueOf());
    
    0 讨论(0)
提交回复
热议问题