如何在javascript中设置查询字符串值,然后重新加载页面

如何在javascript中设置查询字符串值,然后重新加载页面,javascript,Javascript,如何向URL添加查询字符串值,然后刷新该页面 当前url看起来像:/foo/bar 我想重新加载为/foo/bar?tabIndex=4 function onSomethingComplete() { window.location.search = "tabIndex=4"; window.location.reload(); } 谢谢 应该能够执行以下操作: function onSomethingComplete() { var url = win

如何向URL添加查询字符串值,然后刷新该页面

当前url看起来像:/foo/bar

我想重新加载为/foo/bar?tabIndex=4

    function onSomethingComplete() {

    window.location.search = "tabIndex=4";
    window.location.reload();

}

谢谢

应该能够执行以下操作:

function onSomethingComplete() {

    var url = window.location
    url += "?tabIndex=4"
    window.location = url

}

window.location.href+=“tabIndex=4”
window.location.search
已经重新加载了自己。只要我添加了window.location.search;成功了,谢谢!