JS网页在线获取鼠标坐标值的方法

本文实例讲述了JS网页在线获取鼠标坐标值的方法。分享给大家供大家参考。具体实现方法如下:

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />

<title>显示鼠标坐标</title>

</head>

<body onMousemove="micro$oftMouseMove()">

<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>

</html>

希望本文所述对大家的javascript程序设计有所帮助。

以上是 JS网页在线获取鼠标坐标值的方法 的全部内容, 来源链接: utcz.com/z/357262.html

回到顶部