Alibabacloud.com offers a wide variety of articles about documentelement clientwidth, easily find your documentelement clientwidth information here online.
Differentiate between Innerheight and ClientHeight, Innerwidth and ClientWidth, scrollleft and Pagexoffset attributes
Tags:innerheightclientheightinnerwidthclientwidthoffsetleft, etc.
Window object:(1) Innerheight property: The height of the document display area in the window, excluding the menu bar, toolbar, and other parts. This property is readable and writable.IE does not support this property, and the ClientHeight pr
vertical scroll Value
Event.clientxw.document.doc umentelement. The horizontal coordinate of scrolltop relative to the document + The amount of vertical scrolling
The difference between Firefox and IE is as follows:
Ie6.0, ff1.06 +:
Clientwidth = width + padding
Clientheight = height + padding
Offsetwidth = width + padding + border
Offsetheight = height + padding + border
Ie5.0/5.5:
Clientwidth = width-bor
Test the difference between these three properties through a demo.
Description
ScrollWidth: The width of the actual content of the object, not wrapping the edge width, increases as the contents of the object exceed the viewable area.ClientWidth: The width of the visual area of the object's content, not wrapping the edges of the scroll bar, will change with the size of the object display.Offsetwidth: The actual width of the object as a whole, the wrapping line, and so on, will change with the s
ScrollWidthIs the width of the actual content of the object, not the width of the edge, which changes depending on how much content is in the object (the actual width of the object may be changed by more content).ClientWidthIs the width of the object visible, without edges such as the scroll bar, which changes with the window's display size.Offsetwidthis the visible width of the object, and edges such as the package scroll bar change as the window's display size changes.An example of ScrollWidth
1 scrollwidthIs the width of the actual content of the object, excluding edges (border or scrollbar) widths, which change depending on how much content is in the object (more content may change the object's actual degree)2 clientwidthIs the width of the object visible, excluding edges (border or scrollbars), which changes with the window's display size.3 offsetwidthis a The visible width of the object, including edges (border or scrollbars), changes with the window's display size. As an examp
For details about DOM element dimensions, such as offsetWidth, scrollWidth, and clientWidth, offsetwidth
Example:
1. offsetWidth
OffsetWidth = border + padding + height;Here: 50 + 50 + 200 + 50 + 50 = 400
Note:OffsetWidthYou cannot obtain the correct value in the div of display: none. You can use jquery'sOuterWidth ()Correct
2. clientWidth
ClientWidth = pa
The offsetwidth value is always greater than the clientwidth value.Clientwidth is the width (excluding the edge) seen by the object)Offsetwidth is the width seen by the object (including the edge, such as the width occupied by the scroll bar)Scrollheight: gets the scroll height of an object.Scrollleft: sets or obtains the distance between the left-side border of the object and the leftmost end of the currently visible content in the window.Scrolltop:
offsetwidth //Returns the width of the element (including element width, padding, and border, excluding margins)offsetheight //Returns the height of the element (including element height, padding, and border, excluding margins)clientwidth //Returns the width of the element (including element width, padding, excluding borders and margins)clientheight //Returns the height of the element (including element height, padding, excluding borders and margins)S
ScrollWidth: The width of the actual content of the object, without the edge width, becomes larger when the content in the object exceeds the visible area.ClientWidth: The width of the visible area of the object content, the edges such as the scroll bar, and so on, will change with the size of the object display.Offsetwidth: The actual width of the object as a whole, and the edges of the package scroll bar, will change as the object's display size changes.Scenario 1:No content within the element
, these two values are displayed only when the content exceeds the element. For example, if the width is PX, but the actual content is PX, when you drag the scrollbar to the middle position, the content is greater than 25 PX for each element, and the scrollLeft value is 25. Therefore, scrollLeft refers to the distance between the current left boundary of the content and the actual left boundary of the content. The principle of scrollHeight is the same as that of scrollHeight.
OffsetWidth (visibl
Visible area width of the webpage: Document. Body. clientwidthVisible area height: Document. Body. clientheightVisible area width of the webpage: Document. Body. offsetwidthVisible area height: Document. Body. offsetheightWebpage text width: Document. Body. scrollwidthWebpage text height: Document. Body. scrollheightPage size: window. screentopPage to the left: window. screenleftScreen Resolution Height: window. Screen. HeightScreen Resolution width: window. Screen. WidthAvailable screen workspa
In JavaScript, offsetwidth is the visible width of the object, and edges such as the package scrollbar change with the window's display sizeClientWidth, offsetwidth, clientheight differenceIE6.0, ff1.06+:offsetwidth = width + padding + borderoffsetheight = height + padding + borderie5.0/5.5:offsetwidth = widthoffsetheight = heightOffsetwidth: Is the offset width of the element relative to the parent element. equals Border+padding+widthThe difference between offsetwidth,
I. Definition and usage1.event.clientx: The horizontal offset of the event object;Event.clienty: The vertical offset of the event object;2.event.pagex: The event object plus the horizontal offset after the scrolling distance;Event.pagey: The event object plus the vertical offset after the scrolling distance;3.$ (selector). ScrollLeft (offset) =$ (selector). Offset (). Left: Gets or sets the scrolling horizontal position of the object;$ (selector). scrolltop (offset) =$ (selector). Offset (). Top
If the style= "display:none;height:90px;" is set in the HTML element. The properties are not available for offsetleft, offsetwidth,offsettop,offsetheight, and compatibility with better clientheight,clientheight (client). The property will be larger than offset, as it may contain a border or scrollbar, because the browser will not be able to measure it once display:none is not rendered. But you can get the height:90px in the style, and the other CSS property values you set in the style.Style= "Di
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
Offsetwidth: The Border width. clientwidth is not included.
[Ctrl + A select all Note: If you need to introduce external JS, You need to refresh it to execute]
Summing up one night's observation of IE devtoolbar and firebug, we drew these two images to differentiate the nuances of offsetwidth clientwidth scrollwidth scrolltop scrollleft and other attributes, I hope it will help you write JavaScript!
In the first figure, oevent is a parameter object when a time occurs. You don't need to talk about how to obtain it in IE and ff. The entire large background is the full size of the webpage, and the small box in
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.