JavaScript Window Browser Object model

Source: Internet
Author: User

First, Window object:

(1), all browsers support the Window object, which represents the browser window. All JavaScript global objects, functions, and variables automatically become members of the Window object.

(2), the global variable is the property of the Window object, and the global function is the method of the Window object.

Second, Window object methods and properties: (https://www.w3cschool.cn/jsref/obj-window.html)

Third, Window size judgment:

(1) for IE9 to IE9, Chrome, Firefox, Opera and Safari:

Window.innerheight-Internal height of the browser window (including scroll bars)
Window.innerwidth-Internal width of the browser window (including scroll bars)

(2), for IE 8, 7, 6, 5:

Document.documentElement.clientHeight
Document.documentElement.clientWidth
Or
Document.body.clientHeight
Document.body.clientWidth

JavaScript determines the size of all browser windows:

<div id= "Demo" style= ' border:1px solid red ' ></div>
<script>
var W=window.innerwidth | | Document.documentElement.clientWidth | | Document.body.clientWidth;
var H=window.innerheight | | Document.documentElement.clientHeight | | Document.body.clientHeight;
X=document.getelementbyid ("demo");
X.innerhtml= "browser window width:" + w + "px" + ", Height:" + H + "px. "
</script>

JavaScript Window Browser Object model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.