JavaScript 中 screenY 鼠标事件的作用是什么?
htmljavascriptprogramming scripts更新于 2026/1/14 13:00:17
当触发事件时,screenY 鼠标事件返回鼠标指针的垂直坐标。
示例
您可以尝试运行以下代码,以了解如何在 JavaScript 中实现 screenY 鼠标事件。
<!DOCTYPE html>
<html>
<body>
<p onclick = "coordsFunc(event)">单击此处获取鼠标指针的 x(水平)和 y(垂直)坐标。</p>
<script>
function coordsFunc(event) {
var x_coord = event.screenX;
var y_coord = event.screenY;
var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord;
document.write(xycoords);
}
</script>
</body>
</html>
相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

