【问题标题】:javascript - window.location or document.location [duplicate]javascript - window.location 或 document.location [重复]
【发布时间】:2013-02-11 14:24:25
【问题描述】:
window对象的location属性和document对象的location属性有什么区别吗?
window.location || document.location // That is the question.
【问题讨论】:
标签:
javascript
object
browser
【解决方案1】:
这两个对象是相同的:
console.log(window.location === document.location) // true
它们都引用 Location 对象。
【解决方案2】:
window.location represent position in current view of page in browser window
而document.location代表当前显示完整文档/页面的位置
例如在http://www.nationalgeographic.com/ 每日新闻部分是window,向下滚动到最后的整页是document