30

Is javascript code window.location functional in all new and old STANDARD POPULAR browsers?

hippietrail
  • 15,848
  • 18
  • 99
  • 158
EBAG
  • 21,625
  • 14
  • 59
  • 93

3 Answers3

58

window.location, which shares the same structure as document.location should be identical between modern browsers for the following properties:

Known Differences:

  • Only Webkit has location.origin at the time of writing.
Community
  • 1
  • 1
Purrell
  • 12,461
  • 16
  • 58
  • 70
  • 1
    related: 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
  • 2
    window.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
  • Tx for the "location.origin". In fact IE gets all bezerk! ;-) – Pedro Ferreira Feb 16 '18 at 16:24
  • Not true for pathname. – Knu Sep 04 '20 at 18:20
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
  • 3
    Indeed. 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
2

window.location works in all major browsers

Fatih Acet
  • 28,690
  • 9
  • 51
  • 58