为什么window.location.search是空的?
Why is window.location.search empty?
如果我console.log(window.location)
,我得到这个:
Location {replace: function, assign: function, ancestorOrigins: DOMStringList, origin: "https://localhost:3000", hash: "#/account/content?hello=world"…}
ancestorOrigins: DOMStringList
assign: function () { [native code] }
hash: "#/account/content?hello=world"
host: "localhost:3000"
hostname: "localhost"
href: "https://localhost:3000/#/account/content?hello=world'"
origin: "https://localhost:3000"
pathname: "/"
port: "3000"
protocol: "https:"
reload: function reload() { [native code] }
replace: function () { [native code] }
search: ""
toString: function toString() { [native code] }
valueOf: function valueOf() { [native code] }
__proto__: Location
我期望search
是?hello=world
,但它不是。
为什么?
我用的是Chrome 35
因为在您的情况下,?hello=world
不被认为是查询字符串。
它是anchor
(#
)的一部分,可以使用
window.location.hash
相关文章:
- 正在寻找比$(document).ready慢的$(window).load的替代方案
- 直接下载文件,而不是从window.open(url)
- $window.ga在AngularJS事件中未定义
- 如何将PDF作为二进制文件传递到window.open()
- window.onload没有'无法在Android WebView中工作
- window.location替换并传递URL历史记录条目中的变量
- Lucene Search in Alfresco
- window.on.scroll事件未启动
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- 为什么window.open不打开一个以变量形式给出的链接
- window.location使用jquery mobile实现chrome跳转
- window.opener.document在ie中不起作用
- 使用 window.location.search 时,URL 中的字符会更改
- JavaScript window.location.search.substr(1)以空字符串形式返回
- Jquery get window.location.search tag in array
- window.location.href or window.location.search
- 为什么window.location.search是空的?
- 如何在提交表单时将变量捕获到window.location.search中
- window.location.search
- window.location.search.substring在ie8中不工作