日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

JavaScript 里 window, document, screen, body 这几个名词的区别

發布時間:2023/12/19 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 JavaScript 里 window, document, screen, body 这几个名词的区别 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在下面這個 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 这几个名词的区别的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。