DocumentHow can I use JAVASCRIPT to obtain the height and width of the current window? Some time ago, In the csdn programmer development website's communication forum, I saw a friend asking me, and whether the friend asks about the usefulness of this Code, let's take a look at the best answer. This is an example code, all of them are marked, which is of great help to cainiao webmaster.
Reference content is as follows: <Script type = "text/javascript"> Var s = ""; S + = "\ r \ n visible area width of the webpage:" + document.doc umentElement. clientWidth; S + = "\ r \ n visible area of the webpage:" + document.doc umentElement. clientHeight; S + = "\ r \ n visible area width of the webpage:" + document.doc umentElement. offsetWidth + "(including the width of the edge )"; S + = "\ r \ n visible area height of the webpage:" + document.doc umentElement. offsetHeight + "(including the width of the edge )"; S + = "\ r \ n webpage body full text width:" + document.doc umentElement. scrollWidth; S + = "\ r \ n webpage text Height:" + document.doc umentElement. scrollHeight; S + = "\ r \ n webpage volume Height:" + document.doc umentElement. scrollTop; S + = "\ r \ n left when the webpage is rolled:" + document.doc umentElement. scrollLeft; S + = "\ r \ n webpage body part:" + window. screenTop; S + = "\ r \ n left part of the webpage body:" + window. screenLeft; S + = "\ r \ n screen resolution height:" + window. screen. height; S + = "\ r \ n screen resolution width:" + window. screen. width; S + = "\ r \ n available workspace Height:" + window. screen. availHeight; S + = "\ r \ n available workspace width of the screen:" + window. screen. availWidth; Alert (s ); </Script> |
Through the above code, we can clearly see the comments of each statement. We suggest you run the above Code to see the effect!