我想做类似的事情
location.pathname = "/abc"
location.search = "name=test"
它最终被重定向到 /abc
。我希望重定向发生在 /abc?name=test
最佳答案
只需设置位置
(或location.href
):
location = "/abc?name=test";
由于它是相对 URL,因此协议(protocol)和主机将保持不变。
关于javascript - 将 location.pathname 和 location.search 设置在一起?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33938178/