offsetX Property
Gets or sets the x-coordinate of a pointer's position relative to the object firing the event.
Syntax
[ iCoord = ] object.offsetX
Possible Values
iCoord Integer that specifies or receives the x-coordinate, in pixels. The property is read/write. The property has no default value.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are supported in IE7 Standards mode and IE5 (Quirks) mode only. For more information, see About Dynamic Properties and Defining Document Compatibility.
Remarks
The property is read-only in Microsoft Internet Explorer 4.0, and read/write in Internet Explorer 5 and later.
The coordinates match the offsetLeft and offsetTop properties of the object. Use offsetParent to find the container object that defines this coordinate system.
Example
This example uses the offsetX property to determine the mouse position relative to the container that fired the event, and displays the mouse coordinates in the status bar at the bottom of the window.
<SCRIPT> function offsetCoords() { var offsetInfo = "" offsetInfo = "The x coordinate is: " + window.event.offsetX + "\r" offsetInfo += "The y coordinate is: " + window.event.offsetY + "\r" alert(offsetInfo); } </SCRIPT> </HEAD> <BODY onmousemove="window.status = 'X=' + window.event.offsetX + ' Y=' + window.event.offsetY" ondblclick="offsetCoords()"> : <DIV onclick="offsetCoords();" . . . position:absolute; top:200; left:300;"> : </DIV>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/offsetX.htm
Standards Information
There is no public standard that applies to this property.
Applies To
event, Event Constructor
