Is javascript window.location crossbrowser?

15,368

Solution 1

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.

Solution 2

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.

Solution 3

window.location works in all major browsers

Share:
15,368
EBAG
Author by

EBAG

Updated on June 17, 2022

Comments

  • EBAG
    EBAG about 2 years

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

  • Pekka
    Pekka about 13 years
    Indeed. JavaScript was first supported in Netscape 2.0.
  • folktrash
    folktrash over 9 years
    related: window.location.origin is missing in ie10 for windows phone, was added to ie11 msdn.microsoft.com/en-us/library/ie/dn736066(v=vs.85).aspx
  • nktssh
    nktssh over 9 years
    window.location.origin polyfill: if (!window.location.origin) { window.location.origin = window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port: ''); }
  • Pedro Ferreira
    Pedro Ferreira over 6 years
    Tx for the "location.origin". In fact IE gets all bezerk! ;-)
  • Knu
    Knu almost 4 years
    Not true for pathname.