JavaScript 中 screenY 鼠标事件的作用是什么?
htmljavascriptprogramming scripts
当触发事件时,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>