gpt4 book ai didi

javascript - replaceState 为空字符串 : Javascript

转载 作者:行者123 更新时间:2023-11-29 16:04:43 26 4
gpt4 key购买 nike

我有这个网址:

website.com/con?blog=true

我在 javascript 中做的是:

if (getURLparams(blog)) {
RandomFunction();
// change the url
window.history.replaceState({}, '?blog=true', "blog=false");
}

但是,我不想使用 blog=false,实际上我想要空字符串。我尝试了 ""/'' 但它们没有用。任何想法或替代方案?谢谢

最佳答案

您可以将其设置为location.pathname:

window.history.replaceState({}, '', location.pathname);

这将删除 URL 参数。

关于javascript - replaceState 为空字符串 : Javascript,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46805986/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com