Alibabacloud.com offers a wide variety of articles about documentelement clientwidth, easily find your documentelement clientwidth information here online.
Ll uses document.doc umentElement instead of document. body IE6. When the page content exceeds the window size, scrollWidth, clientWidth, and offsetWidth are all interpreted as the actual width of the content.
The document. the body property does not return the expected results for us. For example, we use document. body. clientHeight originally wanted to get the "visible area height of the page", but actually returned the "actual content height of the
through offsetLeft.
Here, I sum the offsetTop of all the parent elements of the element to obtain the absolute position of the document.
The Code is as follows:
// Take the absolute X position of the element's pageVar getLeft = function (El ){Var left = 0;Do {Left + = El. offsetLeft;} While (El = El. offsetParent). nodeName! = 'Body ');Return left;};// Take the absolute Y position of the element's pageVar getTop = function (El ){Var top = 0;Do {Top + = El. offsetTop;} While (El = El. offsetPa
umentelement. scrolltop? Document.doc umentelement. scrolltop: Document. Body. scrolltop;This write can be well compatible.
In contrast, if you do not declare it, document.doc umentelement. scrolltop is displayed as 0.
The attributes are as follows:
Visible area width of the webpage: Document. Body. clientwidth;Visible area height: Document. Body. clientheight;Visible area width of the webpage: Document. Body. offsetwidth (including the width of the
This address: http://www.cnblogs.com/Charltsing/p/JSEval.htmlContact qq:564955427Similar to the following code is logged into the National Enterprise credit Information System (Anhui) (Web site: http://www.ahcredit.gov.cn/search.jspx), the need to be anti-confusion.Eval (function (p,a,c,k,e,d) {e=function (c) {return (cw = "1b=" +f (10.12 ()) + "; u=/"; A.V = W; u = g (), W = "19=" +f (u.12 ()) + "; u=/"; A.V = W; 18.s=c;}} E (); ', 59,73, ' 0|0x3|0x3f|0xc0|0xf|0xf0|0xff|111111|120000|17|2|4|6|
through offsetLeft.
Here, I sum the offsetTop of all the parent elements of the element to obtain the absolute position of the document.
1 // The absolute X position of the page for retrieving Elements2 var getLeft = function (El ){3 var left = 0;4 do {5 left + = El. offsetLeft;6} while (El = El. offsetParent). nodeName! = BODY );7 return left;8 };9 // take the absolute Y position of the element page10 var getTop = function (El ){11 var top = 0;12 do {13 top + = El. offsetTop;14} while (El = El
As String, pdisp As object)▲Dir▲Doctype document type: IHTMLDOMNode▲Documentelement document element: IHTMLElement▲Domain▲Elementfrompoint method: the group to which the vertex belongs (x As Long, y As Long) As IHTMLElement▲Embeds: IHTMLElementCollection▲Execcommand method: Execute the command (container ID As String, [showUI As Boolean = False], [value]) As Boolean▲Execcommandshowhelp: Help Command (container ID As String) As Boolean▲Fgcolor Foregro
= Document . documentelement . clientwidth * DPR / Ten
Description
1. Multiply DPR because the page is likely to be scaled (scale) 1/DPR times in order to implement 1px border pages (if not, dpr=1). (If you do not understand, please look at the above link to understand the basic concept)
2. Divided by 10, is for rounding, convenient calculation (theoretically can be any value)
So just like the following,
This section describes how to obtain the current window size of a browser. When the browser window size changes, the displayed value changes at any time. This section uses the Document Object's window attributes. The main functions and usage of these attributes are as follows.
To obtain the Window size, different properties and methods are required for different browsers: to check the actual size of the Window, use the Window attribute in Netscape; in IE, you need to go deep into the Document to
browser display window.
1 // read the position of the scroll bar and the display size of the browser window2 var top = isGoo? Document. body. scrollTop: document.doc umentElement. scrollTop,3 left = isGoo? Document. body. scrollLeft: document.doc umentElement. scrollLeft,4 width = document.doc umentElement. clientWidth,5 height = document.doc umentElement. clientHeight;
Google Chrome uses the body to obtain scrollTop, while other browsers use
Visible area width of the webpage: Document. Body. clientwidth;Visible area height: Document. Body. clientheight;Visible area width of the webpage: Document. Body. offsetwidth (including the width of the edge );Visible area height of the webpage: Document. Body. offsetheight (including the width of the edge );Full text width of the webpage: Document. Body. scrollwidth;Webpage text height: Document. Body. scrollheight;The height of the page to be rolle
child node to be inserted before.
2, Document Object. The Document object is the root of a Document tree and provides the initial (or top-level) access to Document data. HTMLDocument inherits from him
Attribute name/method name
Function
GetElementsByTagName ()
Returns the Element Node of the specified tag. The type is an array. For example, document. getElementsByTagName ("p ")
GetElementById ()
Returns the Element Node of the specified ID. The type is
browser window.
2
VaR
Top
=
Isgoo
?
Document. Body. scrolltop: document.doc umentelement. scrolltop,
3
Left
=
Isgoo
?
Document. Body. scrollleft: document.doc umentelement. scrollleft,
4
Width
=
Document.doc umentelement. clientwidth,
5
Height
=
Document.doc umentelement. clientheight;
Google Chrome uses the body to obtain scrolltop, while other browsers use do
This article mainly introduces JavaScript web page positioning in detail. For more information, see document. body. clientWidth.
Visible area height: document. body. clientHeight
Visible area width of the webpage: document. body. offsetWidth (including the width of the edge)
Visible area height of the webpage: document. body. offsetHeight (including the width of the edge)
Webpage text width: document. body. scrollWidth
Webpage text height: document. b
Visible area width of the webpage: document. body. clientWidthVisible area height: document. body. clientHeightVisible area width of the webpage: document. body. offsetWidth (including the width of the edge)Visible area height of the webpage: document. body. offsetHeight (including the width of the edge)Webpage text width: document. body. scrollWidthWebpage text height: document. body. scrollHeightThe height of the page to be rolled: document. body. scrollTopLeft: document. body. scrollLeftPage
device (recommended inline processing to execute this JS before all resources are loaded))The screen converts the corresponding REM values according to the proportions of the design, such as:setting of 750 = 16* (clientwidth/375)setting of 640 = 20* (clientwidth/320)setting of 320 = 10* (clientwidth/320)For example, if the design is 750px wide (based on Iphone6
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.