Pick a standard API.offsetY for element-local hit testing.
Keep a fallback helper. Useful when exploring old code.
Do not depend on layerY alone. Non-standard support varies.
Teach both. Know it when you see it; prefer standards when you write it.
Compatibility
Browser Support
MouseEvent.layerY is marked Non-standard on MDN. Engines may implement it, but it is not a safe production baseline like offsetY / pageY.
✓ Non-standard
MouseEvent.layerY
Vertical coordinate relative to the current layer. Non-standard — feature-detect and prefer offsetY, pageY, or clientY for new code.
VariesNon-standard
Google ChromeSupported*
Partial
Microsoft EdgeSupported*
Partial
Mozilla FirefoxSupported*
Partial
Apple SafariSupported*
Partial
OperaSupported*
Partial
Internet ExplorerLegacy
Partial
layerYUse with care
Bottom line: Educational / legacy reading only for most apps. See the MDN layerY reference.
Frequently Asked Questions
It is a read-only number: the vertical mouse coordinate relative to the current layer. Outside positioned elements it is often similar to pageY; inside a positioned element it is relative to that element’s top-left.
MDN marks MouseEvent.layerY as Non-standard on the MouseEvent interface. It is not labeled Deprecated or Experimental, but you should not rely on it in production cross-browser code — prefer offsetY, pageY, or clientY.
pageY is the document Y including scroll. layerY also accounts for scroll, but when the event is inside a positioned element, layerY is relative to that positioned element instead of the whole document.
Prefer standard properties: offsetY for coordinates relative to the event target, pageY for document coordinates, or clientY for viewport coordinates.
Support is limited and non-standard. Always feature-detect (for example "layerY" in event) and provide a fallback using pageY or offsetY.
Yes. layerX is the horizontal counterpart with the same non-standard status and positioning rules.