<html>
<script type="text/javascript">
document.onmousemove = getCursorXY;
function getCursorXY(e) {
document.getElementById('cursorX').value = (window.Event) ? e.pageX : event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
document.getElementById('cursorY').value = (window.Event) ? e.pageY : event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
}
</script>
<body>
<input id="cursorX" size="3">
<input id="cursorY" size="3">
<input type="button" id="button">
</body>
</html>
这样,当页面加载和移动鼠标时,我的鼠标坐标就会显示在输入字段中。我该怎么做
当我
在#按钮上,然后在我
鼠标只在#按钮上移动
提前感谢:)