Retrieves the calculated left position of the object relative to the layout or coordinate parent, as specified by the offsetparent property. dhtml语法 html | n/a |
---|
scripting | [ icoord = ] object.offsetleft |
---|
dhtml可能的值 iCoord | Integer that
receives the left position, in pixels. |
The property is read-only.
The property has no default value.
Remarks You can determine the location, width, and height of an object by using a combination of the offsetLeft, offsettop, offsetheight, and offsetwidth properties. these numeric properties specify the physical coordinates and dimensions of the object relative to the object's offset parent. for more information about how to access the dimension and location of objects on the page through the dynamic html(动态html,即dhtml)燿ocument object model (dom), see measuring element dimension and location.
DHTML代码范例
This example uses the offsetLeft property to determine whether an object is in the user's view. <SCRIPT>
function isinView(oObject)
{
var oParent = oObject.offsetParent;
var iOffsetLeft = oDiv.offsetLeft;
var iClientWidth = oParent.clientWidth;
if (iOffsetLeft > iClientWidth) {
alert("Scroll right for the message.");
}
}
</SCRIPT>
:
<BUTTON onclick="isinView(this)">Click here</BUTTON>
:
<DIV ID=oDiv STYLE="position:absolute; top:200; left:1200;">
:
</DIV> This feature requires Microsoft® Internet Explorer 4.0 or later. Click the following icon to install the latest version. Then reload this page to view the sample.
是否符合公共标准
There is no public standard that applies to this property.
Applies To |
A,
ACRONYM,
ADDRESS,
APPLET,
AREA,
B,
BDO,
BIG,
BLOCKQUOTE,
BODY,
BR,
BUTTON,
CAPTION,
CENTER,
CITE,
CODE,
COL,
COLGROUP,
CUSTOM,
DD,
DEL,
DFN,
DIR,
DIV,
DL,
DT,
EM,
EMBED,
FIELDSET,
FONT,
FORM,
FRAME,
hn,
HR,
I,
IFRAME,
IMG,
INPUT type=button,
INPUT type=checkbox,
INPUT type=file,
INPUT type=image,
INPUT type=password,
INPUT type=radio,
INPUT type=reset,
INPUT type=submit,
INPUT type=text,
INS,
KBD,
LABEL,
LEGEND,
LI,
LISTING,
MAP,
MARQUEE,
MENU,
NOBR,
OBJECT,
OL,
OPTION,
P,
PLAINTEXT,
PRE,
Q,
RT,
RUBY,
S,
SAMP,
SELECT,
SMALL,
SPAN,
STRIKE,
STRONG,
SUB,
SUP,
TABLE,
TBODY,
TD,
TEXTAREA,
TextRange,
TFOOT,
TH,
THEAD,
TR,
TT,
U,
UL,
VAR,
XMP | |
更多语法参考 boundingheight, boundingleft, boundingtop, boundingWidth
|