[Recommendation] details about JS screen computing

Source: Internet
Author: User

During a job, a menu is displayed to move the screen height. the calculated values on the screen vary in different browsers. It is estimated that a small test is performed on the calculation of each attribute on the screen, hoping to help the same degree.

The following are the default values of screen Calculation for new IE pages:
FF and IE both support (computing differences) visible area width of the webpage [document. body. clientWidth]: 1239
FF and IE both support (computing differences) the visible area of the webpage is high [document. body. clientHeight]: 0
FF and IE both support (computing differences) visible area width of the webpage [document. body. offsetWidth]: 1239
FF and IE both support (computing differences) the visible area of the webpage is high [document. body. offsetHeight]: 0
Both FF and IE support (computing differences) The full text width of the webpage [document. body. scrollWidth]: 1239
Both FF and IE support (computing differences) The full text height of the webpage [document. body. scrollHeight]: 0
FF and IE both support (calculation is the same) the height of the page to be rolled [document. body. scrollTop]: 0
FF and IE both support (same calculation) the width of the webpage to be rolled [document. body. scrollLeft]: 0
Only IE is supported: window. screenTop: 144 on the webpage body
Only Internet Explorer is supported. window. screenLeft is displayed on the left of the webpage body.
FF and IE are both supported (the calculation is the same): the screen resolution height [window. screen. height]: 1024
FF and IE support (same calculation): screen resolution width [window. screen. width]: 1280
FF and IE are both supported (the calculation is the same): the height of the available workspace on the screen [window. screen. availHeight]: 990
FF and IE support (same calculation): available workspace width of the screen [window. screen. availWidth]: 1280
Both FF and IE are supported (calculation is different): The left [document. body. offsetLeft] of the form and the right [document. body. offsetTop]: 10 and 15
Both FF and IE support (calculation difference): Form height [document. body. offsetWidth] and width [document. body. offsetHeight]: 1239 and 0
Vertical scroll value: document.doc umentElement. scrollTop
Only the entire width and height of the FF browser are supported, excluding the toolbar [window. innerHeight]: undefined
Ffue and ieboth support (calculate the highest degree of disaster recovery on the webpage: document.doc umentElement. clientHeight): 820
FF and IE are both supported (calculation is the same): Get the maximum distance between the client and the window. document.doc umentElement. scrollTop]: 0

Calculation scope of each attribute of IE browser:

 

The following is the default value for calculating the FF new page screen:
The following are the default values for new page screen calculation:
FF and IE both support (computing differences) visible area width of the webpage [document. body. clientWidth]: 1264
FF and IE both support (computing differences) the visible area of the webpage is high [document. body. clientHeight]: 0
FF and IE both support (computing differences) visible area width of the webpage [document. body. offsetWidth]: 1264
FF and IE both support (computing differences) the visible area of the webpage is high [document. body. offsetHeight]: 0
Both FF and IE support (computing differences) The full text width of the webpage [document. body. scrollWidth]: 1264
Both FF and IE support (computing differences) The full text height of the webpage [document. body. scrollHeight]: 0
FF and IE both support (calculation is the same) the height of the page to be rolled [document. body. scrollTop]: 0
FF and IE both support (same calculation) the width of the webpage to be rolled [document. body. scrollLeft]: 0
Only Internet Explorer is supported: window. screenTop: undefined
Only Internet Explorer is supported. window. screenLeft is the left part of the webpage body. undefined is supported.
FF and IE are both supported (the calculation is the same): the screen resolution height [window. screen. height]: 1024
FF and IE support (same calculation): screen resolution width [window. screen. width]: 1280
FF and IE are both supported (the calculation is the same): the height of the available workspace on the screen [window. screen. availHeight]: 990
FF and IE support (same calculation): available workspace width of the screen [window. screen. availWidth]: 1280
Both FF and IE are supported (calculation is different): The left [document. body. offsetLeft] of the form and the right [document. body. offsetTop]: 0 and 0
Both FF and IE support (calculation difference): Form height [document. body. offsetWidth] and width [document. body. offsetHeight]: 1264 and 0
Vertical scroll value: document.doc umentElement. scrollTop
Only the entire width and height of the FF browser are supported, excluding the toolbar [window. innerHeight]: 829
Ffue and ieboth support (calculate the highest degree of disaster recovery on the webpage: document.doc umentElement. clientHeight): 858
FF and IE are both supported (calculation is the same): Get the maximum distance between the client and the window. document.doc umentElement. scrollTop]: 0

The above data shows that, in FF and IE, when calculating the screen width, FF is 25 pixels more than IE.

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.