gpt4 book ai didi

javascript - 从 URL 检索哈希值

转载 作者:行者123 更新时间:2023-11-28 05:09:45 25 4
gpt4 key购买 nike

我正在尝试设置一个表单,从 URL 中获取哈希值,然后使用该值来确定要检查的 radio 输入。后一部分正在工作,但我无法使哈希检索工作。

var url = document.referrer;
var dec= decodeURIComponent(url.replace(/\+/g, '%20'));
var hash = url.substring(url.indexOf('?')+1);
var hash = decodeURI(hash);

在 Firefox 控制台中,我尝试“console.log(hash)”,但只是收到一个引用错误,指出“哈希未定义”。

如果需要的话,整个脚本都在这里 - http://pastebin.com/Yq9NbHyz

最佳答案

因为hash不是全局变量。使用window.location.hashlocation.hash

关于javascript - 从 URL 检索哈希值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41463771/

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