What's the difference between window.location and document.location in JavaScript?
问题 Should both of them reference the same object? 回答1: 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 回答2: The canonical way to get the current location object is window.location (see this MSDN page from 1996 and the W3C draft from 2006). Compare this to document.location , which originally only returned the current URL as a string (see this