<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<%@ page language="java" %>
<%@ page contentType="text/html;charset=UTF-8"%>
<head>
<title>鼠标位置</title>
<script type="text/javascript">
function $(id){
return document.getElementById(id);
}
function body_onclick(e){
event = e||window.event;
$("x-position").value=event.x;
$("y-position").value=event.y;
}
</script>
<style>
.position{
width:1000px;
height:500px;
text-align:center;
color: gold;
background-color: #6090dd;
font-size:24pt;
margin: 0 auto;
}
</style>
</head>
<body onmousemove="body_onclick(event)">
<div class="position">
当前鼠标坐标:
x<input value="0" id="x-position" size="6"/>
y<input value="0" id="y-position" size="6"/>
</div>
</body>
</html>
JS获取鼠标坐标
最新推荐文章于 2021-08-03 11:18:53 发布