我想知道 location.search.substring(1)
到底做了什么。我在某个网站上看到了这段代码。我尝试使用 alert
打印,但这没有给出任何结果。它应该提醒位置 href 吗?
alert(location.search.substring(1))
最佳答案
http://example.com/index.php?foo=bar
location.search
> ?foo=bar
location.search.substring(1)
> foo=bar
这样代码将返回整个查询参数,不带问号。
关于javascript - javascript 中的 location.search 是什么,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14395090/