javascriptwindow.location

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


What's the difference between window.location and document.location? Should both of them reference the same object?


Solution

  • 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