gpt4 book ai didi

javascript - #js中URL地址中的变量

转载 作者:行者123 更新时间:2023-11-30 08:14:52 25 4
gpt4 key购买 nike

如何从 URL 地址中检索变量?我正在使用此代码,但它不起作用:

var x=window.location;
var y = x.indexOf('#', 0);
x=x.substring(y,x.length);

我收到以下错误:

Error: x.indexOf is not a function

最佳答案

你要的不是window.location而是window.location.href

不过,我会使用 window.location.hash

关于javascript - #js中URL地址中的变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5336534/

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