OffsetTop can be used to obtain the position of the HTML element from the top or the outer element. style. top is also supported. The difference between the two is:
1. offsetTop returns numbers, while style. top returns strings. In addition to numbers, it also has the unit: px.
Ii. offsetTop read-only, while style. top can be read and written.
3. If the top style is not specified for the HTML element, style. top returns an empty string.
OffsetLeft, style. left, offsetWidth, style. width, offsetHeight, and style. height are the same principles.
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: sets or obtains the distance between the top of the object and the top of the visible content in the window.
ScrollWidth: gets the scroll width of an object.
OffsetHeight: gets the height of an object relative to the layout or the parent coordinate specified by the parent coordinate offsetParent attribute.
OffsetLeft: obtains the left position of the object relative to the layout or the parent coordinate specified by the offsetParent attribute.
OffsetTop: obtains the top position of an object relative to the layout or the parent coordinate specified by the offsetTop attribute.
The horizontal coordinates of event. clientX relative to the document
The vertical coordinates of event. clientY relative to the document
Horizontal coordinates of event. offsetX relative to the container
Event. offsetY vertical coordinates of the container
Document.doc umentElement. scrollTop 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-border
ClientHeight = height-border
OffsetWidth = width
OffsetHeight = height
(The margin attribute in CSS is irrelevant to clientWidth, offsetWidth, clientHeight, and offsetHeight );
IE ---------------------
Webpage visible area width document. body. clientWidth
The visible area of the webpage is high in document. body. clientHeight.
Webpage visible area width (including edge width) document. body. offsetWidth
The visible area height of the webpage (including the width of the edge) document. body. offsetHeight
Webpage full text width document. body. scrollWidth
Webpage text height document. body. scrollHeight
High document. body. scrollTop
Left document. body. scrollLeft
Window. screenTop
Window. screenLeft
Screen Resolution height window. screen. height
Screen Resolution width window. screen. width
Screen available workspace height window. screen. availHeight
Available screen workspace width window. screen. availWidth
Copy codeThe Code is as follows:
// Object coordinates
Var oRect = document. getElementById ("divHotImg"). getBoundingClientRect ();
X = oRect. left
Y = oRect. top
// Alert ("(" + x + "," + y + ")")
If (ns4 | ns6 ){
X = e. pageX;
Y = e. pageY;
}