javascript window.location 是跨浏览器吗?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5615273/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is javascript window.location crossbrowser?
提问by EBAG
Is javascript code window.location functional in all new and old STANDARD POPULAR browsers?
javascript 代码 window.location 在所有新旧标准流行浏览器中都有效吗?
回答by Purrell
window.location
, which shares the same structure as document.location
should be identical between modern browsers for the following properties:
window.location
,它共享相同的结构,document.location
现代浏览器之间的以下属性应该相同:
hash
(except in FireFox ~< 16.0 where there was a bug with encoding)hostname
href
pathname
port
protocol
search
reload()
replace()
hash
(除了在 FireFox ~< 16.0 中存在编码错误)hostname
href
pathname
port
protocol
search
reload()
replace()
Known Differences:
已知差异:
- Only Webkit has
location.origin
at the time of writing.
location.origin
在撰写本文时,只有 Webkit 有。
回答by Jim Blackler
I can't say 'all old browsers' since it may not work in Netscape Navigator 0.9 but yeah this is in the standard and is very widely supported.
我不能说“所有旧浏览器”,因为它可能无法在 Netscape Navigator 0.9 中工作,但是这是标准的并且得到了广泛的支持。
回答by Fatih Acet
window.location works in all major browsers
window.location 适用于所有主要浏览器