MouseEvent.pageX is a read-only number: the horizontal pointer position in CSS pixels from the left edge of the entire document, including content scrolled out of view.
Read the notes below before you rely on this property. Prefer feature detection when support is limited.
Syntax
Use event.pageX. Start with this line.
JavaScript
event.pageX
Call
What it does
event.pageX
Primary signature.
Built into the browser. Read event.pageX on a MouseEvent — no import required.
Library declarations
JavaScript
event.pageX
Parameters
Parameter
Description
Mouse / pointer event
Required. Source of pageX
window.scrollX
Optional. Explains pageX ≈ clientX + scrollX
Return Value
Return Value
Description
*
The current value of event.pageX.
JavaScript Examples
Example 1 — Log pageX / pageY
MDN-style demo: print document coordinates while you move.
JavaScript
const x = document.getElementById("x");
const y = document.getElementById("y");
function updateDisplay(event) {
x.textContent = event.pageX;
y.textContent = event.pageY;
}
document.addEventListener("mousemove", updateDisplay);
Listen on a box. The click still carries all three X properties.
Document X.pageX places the click on the full page.
Local X.offsetX places the click inside the element.
Choose by job. Markers on a scrolled page → pageX; hit-test inside a control → offsetX.
Compatibility
Browser Support
MouseEvent.pageX is Baseline Widely available (MDN: since July 2015). It is not Deprecated, Experimental, or Non-standard.
✓ Baseline · Widely available
MouseEvent.pageX
Document-relative horizontal pointer coordinate — includes horizontal scroll for absolute page positions.
UniversalWidely available
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions · Chromium & Legacy
Full support
Internet ExplorerIE 6+ · Legacy environments
Full support
OperaAll modern versions
Full support
pageXExcellent
Bottom line: Safe to use in modern browsers. Pair with pageY for document points; use clientX for viewport-only work and offsetX for element-local hits.
Frequently Asked Questions
It is a read-only number: the horizontal mouse position in CSS pixels relative to the left edge of the entire document, including any part of the page that is scrolled out of view.
No. MDN marks MouseEvent.pageX as Baseline Widely available (since July 2015). It is not Deprecated, Experimental, or Non-standard.
pageX includes horizontal scroll. MDN’s example: if 200px of the left side is scrolled away and you click 100px from the viewport’s left edge, pageX is 300.
clientX is relative to the viewport and ignores document scroll. pageX is relative to the document and grows when you scroll right. Often: pageX ≈ clientX + window.scrollX.
offsetX is relative to the target element’s padding edge. pageX is relative to the whole document. Use offsetX for clicks inside a box; use pageX for positions on a scrolled page.
A double floating-point number of pixels. It was originally defined as a long integer; the CSSOM View Module redefined it as a double for subpixel precision.