Sets or retrieves the x-coordinate of the mouse pointer's position relative to the object firing the event.
dhtml语法
event.offsetX [ = iCoord ]
DHTML可能的值
iCoord | Integer that
specifies or receives the x-coordinate, in pixels. |
The property is read/write.
The property has no default value.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see about dynamic properties.
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.
DHTML代码范例
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>
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