MouseEvent pageY Property
Przykład
Podaj współrzędne wskaźnika myszy po kliknięciu przycisku myszy na elemencie:
var x = event.pageX; // Get the horizontal coordinate
var y = event.pageY; // Get the vertical coordinate
var coor = "X coords: " + x + ", Y coords: " + y;
Więcej przykładów „Wypróbuj sam” poniżej.
Definicja i użycie
Właściwość pageY zwraca współrzędną pionową (zgodnie z dokumentem) wskaźnika myszy, gdy zostało wyzwolone zdarzenie myszy.
Dokumentem jest strona internetowa.
Wskazówka: Aby uzyskać współrzędną poziomą (zgodnie z dokumentem) wskaźnika myszy, użyj właściwości pageX .
Uwaga: ta właściwość jest tylko do odczytu.
Uwaga: ta właściwość jest niestandardowa, ale działa w większości głównych przeglądarek.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
pageY | Yes | 12.0 | Yes | Yes | Yes |
Składnia
event.pageY
Szczegóły techniczne
Wartość zwrotu: | Liczba reprezentująca pionową współrzędną wskaźnika myszy w pikselach |
---|---|
Wersja DOM: | Nic |
Więcej przykładów
Przykład
Podaj współrzędne wskaźnika myszy, gdy wskaźnik myszy przesuwa się nad elementem:
var x = event.pageX;
var y = event.pageY;
var coor = "X coords: " + x + ", Y coords: " + y;
document.getElementById("demo").innerHTML = coor;
Przykład
Demonstracja różnic między clientX i clientY oraz screenX i screenY:
var pX = event.pageX;
var cX = event.clientX;
var pY = event.pageY;
var cY = event.clientY;
var coords1 = "page - X: " + pX + ", Y coords: " + pY;
var coords2 = "client - X: " + cX + ", Y coords: " + cY;
Powiązane strony
Odniesienie HTML DOM: MouseEvent pageX Property
Odniesienie HTML DOM: MouseEvent clientX Property
Odniesienie HTML DOM: MouseEvent clientY Property
Odniesienie HTML DOM: Właściwość MouseEvent screenX
Odniesienie HTML DOM: MouseEvent screenY Property