如何附加或更新timestamp querystring参数 [英] How do I Attach or update a timestamp querystring parameter
问题描述
我想在我的查询字符串中附加时间戳,以确保浏览器在通过javascript刷新页面时绕过其缓存。我需要考虑现有的查询字符串(可能已经有一个时间戳参数)和哈希标记( http://www.example.com/?ts=123456#example
)。
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 existing querystring (which might already have a timestamp parameter in it) and for the hash tag (http://www.example.com/?ts=123456#example
).
我编写了自己的实现,但我怀疑它不必要地复杂化。是否有快速简单或至少优雅的方法来实现这一目标?
I have written my own implementation but I suspect that its unnecessarily complicated. Is there a quick-and-easy or at least elegant way of accomplishing this?
推荐答案
为了操纵查询字符串参数我推荐你这个插件:
For manipulating the query string parameters I recommend you this plugin:
- query-object
这很容易使用:
var timestamp = $.query.get('ts'); // get a value
window.location = $.query.set('ts', newValue); // set a value and navigate
这篇关于如何附加或更新timestamp querystring参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!