在下面这个 StackOverflow 的线索里进行了讨论:

https://stackoverflow.com/questions/9895202/what-is-the-difference-between-window-screen-and-document-in-javascript

window

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

相当于 浏览器 JavaScript 编程环境里的 root 对象,也可以看成是 document 对象模型的父节点。作为全局对象被访问。

window.screen

window 全局对象的一个属性,包含了物理屏幕的尺寸信息。

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

window.document

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

页面被渲染后的可见部分对应的 DOM 对象。

body

是上文描述的 document 对象中一个名为 body 的子节点。

Since window is the global object you can reference any properties of it with just the property name - so you do not have to write down window. - it will be figured out by the runtime.

因为 window 是全局对象,因此访问其属性时,可以省略 window. 的写法。

因此通过下列方式访问 window 里的属性,同样有效:

更多Jerry的原创文章,尽在:“汪子熙”:

JavaScript 里 window, document, screen, body 这几个名词的区别相关推荐

  1. javascript里的document.all用法收集

    javascript里的document.all用法   从IE4开始IE的object model才增加了document.all[],来看看document.all[]的Description: ...

  2. javascript 中的window, document, screen都有什么区别?

    谷歌之后,从stackoverflow上找到的高赞答案: https://stackoverflow.com/questions/9895202/what-is-the-difference-betw ...

  3. JavaScript window.document的属性、方法和事件小结

    javascript中window.document的属性.方法和事件的总结,有需要的朋友可参考一下本文章. 属性: Attributes 存储节点的属性列表(只读) childNodes 存储节点的 ...

  4. 关于js获取屏幕高度和宽度( window.document.body,window.screen)(PC端和移动端)

    在使用JS的时候经常遇到的问题就是我需要获取当前屏幕的宽度和高度.每每到这个时候不知道使用哪个: widow.document.body.offsetWidth; window.screen.avai ...

  5. JS中window.document对象

    小知识点注:外面双引号,里面的双引号改为单引号:                  在div里面行高设置和整个外面高度一样,才能用竖直居中,居中是行居中                  文本框取出来 ...

  6. HTML Window.document

    1.Window.document对象 一.找到元素:     docunment.getElementById("id"):根据id找,最多找一个:     var a =doc ...

  7. javascript里的面向对象

    2019独角兽企业重金招聘Python工程师标准>>> 前言: javascript 项目中原生态的语法用得比较少了,都是基于jQuery开发,但在移动项目中还是比较麻烦的.想整理个 ...

  8. document 和 window.document

    通常我在写javascript的时候从来没有意识到document和window.document之间是有区别的,实际使用过程中也确实没有遇到问题,但是这埋下了非常大的隐患,当出现问题时,这个bug就 ...

  9. IE里Window的Method列表

    ie里window的method列表 alert(sMsg) //弹出一个确认消息框 attachEvent(sEvent,pFunction) //绑定一个函数到某个事件,事件触发时随机执行其中一个 ...

最新文章

  1. 总有些物理现象颠覆你的想象
  2. Android 从清单配置文件元数据中获取值
  3. 滴滴快车奖励政策,高峰奖励,翻倍奖励,按成交率,指派单数分级(11月9日~11月13日)...
  4. tomcat 页面图片 管理 服务器 配置
  5. js javascript UTF-8 GB2312编码转换
  6. [react] 在React中组件和元素有什么区别?
  7. Taro+react开发(36)每一个节点要一个view包裹
  8. vmware挂载san存储_戏说 块存储 文件存储 对象存储
  9. ANDROID 中设计模式的採用--结构型模式
  10. MySQL 6.子查询
  11. HDU 3468 HDOJ 3468 A Simple Problem with Integers ACM 3468 IN HDU
  12. 【python】多进程小结
  13. Chrome浏览器无法访问网页(移动硬盘)
  14. android 字幕跑马灯,led跑马灯字幕
  15. PostgreSQL RULE
  16. python实现最小二乘法
  17. 硬件电路设计原理图设计
  18. missing external certificate的解决方案
  19. 微信小程序——tabBar使用
  20. 推荐100首值得听的英文歌【ZT】

热门文章

  1. 课后作业之字符串加密
  2. CentOS7下安装GUI图形界面
  3. 有用的SQL 语句(转)
  4. Git 常用命令及讲解(不断更新)
  5. ##MySql数据库表的操作与应用
  6. sh 脚本执行sql文件传参数
  7. 077 Apache的HBase与cdh的hue集成(不建议不同版本之间的集成)
  8. HDU 1284 钱币兑换问题 (完全背包)
  9. 迷你图标集大集合:5000+ 30套免费的图标(不得不下,设计必备)
  10. ecshop静态、 ecshop伪静态、ecshop伪静态设置详细方法、ECSHOP静态化方法