Is javascript code window.location functional in all new and old STANDARD POPULAR browsers?
The location property of a window (i.e. window. location ) is a reference to a Location object; it represents the current URL of the document being displayed in that window. Since window object is at the top of the scope chain, so properties of the window. location object can be accessed without window.
All modern browsers map document. location to the window. location but you can prefer window.
See the question IE incompatability with window. location. href. But yes, it's better to use href as a property, which will work in any browser, including IE.
The window.location object can be used to get the current page address (URL) and to redirect the browser to a new page.
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:
location.origin
at the time of writing.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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With