Home | Top | Web development | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.


offsetParent Property

Retrieves a reference to the container object that defines the offsetTop and offsetLeft properties of the object.

Syntax

HTML Scripting
N/A
[ oElement = ] object.offsetParent

Possible Values

oElement Object that receives the container object.

The property is read-only. The property has no default value.

Remarks

Most of the time the offsetParent property returns the body object.

Note   In Microsoft® Internet Explorer 5, the offsetParent property returns the table object for the td object; in Internet Explorer 4.0 it returns the tr object. You can use the parentElement property to retrieve the immediate container of the table cell.

Example

This example shows how to determine the position of a td object. Although the td object appears to the far right in the document, its position is close to the x-axis and y-axis, because its offset parent is a table object rather than the document body. For Internet Explorer 4.0, this same example returns a position of 0,0 because the offset parent is the table row.

 

<HTML>
<HEAD> <TITLE>Elements: Positions</TITLE>
<SCRIPT LANGUAGE="JScript">
function showPosition()
{ var oElement = document.all.oCell;
alert("The TD element is at (" + oElement.offsetLeft + "," + oElement.offsetTop + ")\n" + "The offset parent is " + oElement. offsetParent .tagName ); }
</SCRIPT> </HEAD>
<BODY onload="showPosition()">
<P>This document contains a right-aligned table. <TABLE BORDER=1 ALIGN=right> <TR> <TD ID=oCell>This is a small table.</TD> </TR> </TABLE> </BODY> </HTML>

Standards Information

There is no public standard that applies to this property.

Applies To

SUB Platform Version
Win16: 4.0
Win32: 4.0
Windows CE: 4.0
Unix: 4.0
Mac: 4.0
 
A , ACRONYM , ADDRESS , APPLET , AREA , B , BDO , BIG , BLOCKQUOTE , BODY , BR , BUTTON , CAPTION , CENTER , CITE , CODE , COL , COLGROUP , COMMENT , 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=hidden , 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 , TFOOT , TH , THEAD , TR , TT , U , UL , VAR , XMP
Home | Top | Web development | JavaScript Editor JavaScript EditorGet Advanced
JavaScript and Ajax Editor,
Validator and Debugger!

1st JavaScript Editor.