aspxtreme

offsetY Property

event Properties   DHTML Events


DOM Level 2 Specification.

Retrieves the vertical position of the mouse relative to the object firing the event.

Syntax


HTML N/A
Script [ iCoord = ] event.offsetY

Possible Values


iCoord Integer representing the vertical coordinate, in pixels.

The property is read-only with no default value.

Remarks

This property returns the y-coordinate of the cursor position at which the event occurred, relative to the top edge of the object where the event is contained.

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

Example

The following example demonstrates use of the offsetY property to determine the mouse position relative to the container that fired the event. The status window shows the mouse position at all times relative to the body.

<script language="JavaScript">
function offsetCoords ( ) {
var el = event.srcElement.tagName;
var offsetInfo = "";
offsetInfo = "The offsetX coordinate 
  relative to the "+el+" is: " + 
  window.event.offsetX + "\r"
offsetInfo += "The offsetY coordinate 
  relative to the "+el+" is: " + 
  window.event.offsetY + "\r"
alert ( offsetInfo );
}
</script>
<body onmousemove="window.status='X " + 
  window.event.offsetX + ' Y " + 
  window.event.offsetY" ondblclick="offsetCoords ( )">
Double click anywhere ...
<div onclick="offsetCoords ( );"
  style="width:400; background:black; color:khaki;
  padding:20">Click in this black ... </div>

This feature requires Microsoft® Internet Explorer® 4.0 or later.

 Show me 

Applies To

event

See Also

clientX, clientY, offsetX, screenX, screenY



Books and more ...

Contents
HTML Elements / DOM Objects
HTML Element Attributes
CSS Attributes
DOM Object Properties
DOM-compliant Events Reference
DOM Methods Reference
DOM Collections Reference
 


Suggested Reading



Previous page Back to top Next page

Check out related books at Amazon

© 2000-2008 Rey Nuñez All rights reserved.

If you have any question, comment or suggestion
about this site, please send us a note

You can help support aspxtreme