JavaScript中的window.location和document.location有什么区别? [英] What's the difference between window.location and document.location in JavaScript?

查看:187
本文介绍了JavaScript中的window.location和document.location有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

两者是否应该引用同一个对象?

Should both of them reference the same object?

推荐答案

根据W3C,它们是相同的。实际上,对于跨浏览器安全性,您应该使用 window.location 而不是 document.location

According to the W3C, they are the same. In reality, for cross browser safety, you should use window.location rather than document.location.

请参阅: http:// www.w3.org/TR/html/browsers.html#dom-location

这篇关于JavaScript中的window.location和document.location有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆