日期:2014-05-19  浏览次数:20846 次

获取鼠标位置,并相应--显示其当前坐标
鼠标移动到那里,都会有其坐标的显示,是以那种紧随鼠标的白色框显示的,
其内容是鼠标的坐标。
谢谢

------解决方案--------------------
脚本说明:
第一步:把如下代码加入 <body> 区域中:
<SCRIPT LANGUAGE= "JavaScript ">
if (navigator.appName == 'Netscape ')
{
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = netscapeMouseMove;
}

function netscapeMouseMove(e) {
if (e.screenX != document.test.x.value && e.screenY != document.test.y.value)
{
document.test.x.value = e.screenX;
document.test.y.value = e.screenY;
}
}

function micro$oftMouseMove() {
if (window.event.x != document.test.x.value && window.event.y != document.test.y.value)
{
document.test.x.value = window.event.x;
document.test.y.value = window.event.y;
}
}
</SCRIPT>
<FORM NAME= "test ">
X: <INPUT TYPE= "TEXT " NAME= "x " SIZE= "4 "> Y: <INPUT
TYPUE= "TEXT " NAME= "y " SIZE= "4 ">
</FORM>


第二步:把 <body> 中内容改为:
<body bgcolor= "#fef4d9 " onMousemove= "micro$oftMouseMove() ">