What's the difference between window.location and document.location in JavaScript?

Morgan Cheng picture Morgan Cheng · Mar 12, 2010 · Viewed 107.1k times · Source

Should both of them reference the same object?

Answer

rahul picture rahul · Mar 12, 2010

According to the W3C, they are the same. In reality, for cross browser safety, you should use window.location rather than document.location.

See: http://www.w3.org/TR/html/browsers.html#dom-location