0 out of 2 rated this helpful - Rate this topic

offsetY property

Sets or retrieves the y-coordinate of a pointer's position relative to the object firing the event.

Syntax

JavaScript

p = object.offsetY

Property values

Type: Integer

the y-coordinate, in pixels.

Remarks

This property is read-only in Microsoft Internet Explorer 4.0, and read/write in Microsoft Internet Explorer 5 and later.

This property is read/write.

The coordinates match the offsetLeft and offsetTop properties of the object. Use offsetParent to find the container object that defines this coordinate system.

Examples

This example uses the offsetY 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.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/offsetY.htm


<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>

 

 

Send comments about this topic to Microsoft

Build date: 3/14/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ