screenX鼠标事件在JavaScript中的作用是什么?
触发事件时,screenX鼠标事件将返回鼠标指针的水平坐标。
示例
您可以尝试运行以下代码,以了解如何在JavaScript中实现screenX Mouse事件。
<!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.screenX;
var y_coord = event.screenY;
var xycoords = "X coords= " + x_coord + ", Y coords= " + y_coord;
document.write(xycoords);
}
</script>
</body>
</html>热门推荐
10 档案调动孩子祝福语简短
11 周末愉快祝福语高级简短
12 哥哥中考加油祝福语简短
13 保持快乐祝福语大全简短
14 关于早晨的祝福语简短
15 求助短信生日祝福语简短
16 贺卡祝福语宝宝男孩简短
17 2026祝福语简短创意牛
18 给儿子祝福语简短霸气