Is javascript code window.location functional in all new and old STANDARD POPULAR browsers?
Asked
Active
Viewed 1.6k times
30
-
4As long as Javascript is turned on... :D – Jared Farrish Apr 10 '11 at 22:59
-
How old is old? I doubt it'll work in Mosaic... – Blender Apr 10 '11 at 23:00
-
That's a good point and I didn't wrote my question right, I meant all STANDARD POPULAR Browsers, which they aren't too many. – EBAG Apr 10 '11 at 23:04
-
isn't keyword crossbrowser for that? – EBAG Apr 10 '11 at 23:06
-
@EBAG: try putting asterisks on both ends of a word you want to stress and *this* is the result. CAPS ARE CONSIDERED YELLING – qwertymk Apr 11 '11 at 00:55
3 Answers
58
window.location
, which shares the same structure as document.location
should be identical between modern browsers for the following properties:
hash
(except in FireFox ~< 16.0 where there was a bug with encoding)hostname
href
pathname
port
protocol
search
reload()
replace()
Known Differences:
- Only Webkit has
location.origin
at the time of writing.
-
1related: window.location.origin is missing in ie10 for windows phone, was added to ie11 http://msdn.microsoft.com/en-us/library/ie/dn736066(v=vs.85).aspx – folktrash Nov 07 '14 at 21:39
-
2window.location.origin polyfill: if (!window.location.origin) { window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); } – nktssh Jan 23 '15 at 12:33
-
-
16
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.

Jim Blackler
- 22,946
- 12
- 85
- 101
-
3Indeed. JavaScript was first supported in [Netscape 2.0](http://en.wikipedia.org/wiki/Netscape_Navigator#The_rise_of_Netscape). – Pekka Apr 10 '11 at 22:59