【发布时间】:2016-10-14 11:49:20
【问题描述】:
我有两个不同的查询字符串:?pid= 和 ?ref=。目前我使用window.history.pushState 添加查询字符串。如何检查是否已经存在查询字符串以避免使用?pid=foo?ref=bar 而不是?pid=foo&ref=bar?
当前代码:
if (!!$.cookie('myrefcookie')) {
var myref = $.cookie("myrefcookie")
var target = window.location.href + '?ref=' + myref;
window.history.pushState(null, null, target);
}
【问题讨论】:
标签: javascript jquery query-string