Javascript中的窗口,屏幕和文档有什么区别? [英] What is the difference between window, screen, and document in Javascript?

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

问题描述

我认为这些术语可以互换使用,作为DOM的全局环境。有什么区别(如果有的话)我应该在何时使用每一个?

I see these terms used interchangeably as the global environment for the DOM. What is the difference (if there is one) and when should I use each one?

推荐答案

窗口是主要的JavaScript对象根,也就是浏览器中的全局对象,也可以视为文档对象模型的根。您可以在大多数情况下(在浏览器中)以窗口的形式访问它;

Window is the main JavaScript object root, aka the global object in a browser, also can be treated as the root of the document object model. You can access it as window in most of the cases (in the browser);

window.screen 是一个关于物理屏幕尺寸的小信息对象。

window.screen is a small information object about physical screen dimensions.

window.document 或只是 document 是可见(或更好的:渲染)文档对象模型/ DOM的主要对象。

window.document or just document is the main object of the visible (or better yet: rendered) document object model/DOM.

这篇关于Javascript中的窗口,屏幕和文档有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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