窗口对象的位置属性与文档对象的位置属性之间是否有区别?javascript - window.location或document.location
window.location || document.location // That is the question.
- 是它们的属性相同?
- 他们有不同的浏览器支持吗?
窗口对象的位置属性与文档对象的位置属性之间是否有区别?javascript - window.location或document.location
window.location || document.location // That is the question.
这两个对象是相同的:
console.log(window.location === document.location) // true
它们都指向位置的对象。
为什么有两种方法可以访问同一个对象? – 2013-02-26 07:52:53
window.location represent position in current view of page in browser window
和document.location
代表目前显示全文件/页面位置
e.g在http://www.nationalgeographic.com/高达DAILY NEWS部分是window
和向下滚动,直到结束整页是document
@adeneo感谢您的链接。 [@ Christoph的回答](http://stackoverflow.com/a/2431375/552067)很有见地。投票结束我的问题。 – 2013-02-26 07:58:23