當鼠標事件被觸發(fā)時,pageY鼠標事件屬性用于獲取鼠標指針的垂直坐標。坐標是相對于屏幕的。
示例
您可以嘗試運行以下代碼來了解如何實現(xiàn)pageY?JavaScript 中的鼠標事件。
<!DOCTYPE html>
<html>
<body>
<p onclick="coordsFunc(event)">Click here to get the x (horizontal) and y (vertical) coordinates of the mouse pointer.</p>
<script>
function coordsFunc(event) {
var x_coord = event.pageX;
var y_coord = event.pageY;
var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord;
document.write(xycoords);
}
</script>
</body>
</html>
登錄后復制
以上就是在JavaScript中,pageY鼠標事件的作用是什么?的詳細內(nèi)容,更多請關注www.92cms.cn其它相關文章!






