两个问题
1.window 和 document 的区别?
window 表示浏览器中打开(包含DOM文档)的窗口
window 是可以省略的,如 alert();window.alert()
document 表示任何在浏览器中已经加载好的网页,并作为一个入口去操作网页内容(也就是DOM tree)
document 对象是 window 对象的一部分,如 document.body;window.document.body
2.window.location 和 document.location 一样吗?
window.location 只读属性,返回一个 Location 对象,表示该窗口当前显示文档的URL相关信息
document.location 只读属性,返回一个 Location 对象,表示该文档的URL相关信息window.location === document.location;//true 即使在 iframe 中也是一样的
尽管 window.location 是一个只读 Location 对象,你仍然可以赋给它一个 DOMString。
这意味着您可以在大多数情况下处理 location,就像它是一个字符串一样:window.location = 'http://www.example.com',
是 window.location.href = 'http://www.example.com'的同义词


