JS網(wǎng)頁在線獲取鼠標(biāo)坐標(biāo)值的方法
更新時間:2015年02月28日 10:27:28 投稿:shichen2014
這篇文章主要介紹了JS網(wǎng)頁在線獲取鼠標(biāo)坐標(biāo)值的方法,涉及javascript操作頁面窗口位置元素的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實例講述了JS網(wǎng)頁在線獲取鼠標(biāo)坐標(biāo)值的方法。分享給大家供大家參考。具體實現(xiàn)方法如下:
復(fù)制代碼 代碼如下:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>顯示鼠標(biāo)坐標(biāo)</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>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>顯示鼠標(biāo)坐標(biāo)</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程序設(shè)計有所幫助。
相關(guān)文章
JavaScript類數(shù)組對象轉(zhuǎn)換為數(shù)組對象的方法實例分析
這篇文章主要介紹了JavaScript類數(shù)組對象轉(zhuǎn)換為數(shù)組對象的方法,結(jié)合實例形式分析了javascript類數(shù)組對象的功能,以及類數(shù)組對象轉(zhuǎn)換為數(shù)組對象的相關(guān)方法與實現(xiàn)技巧,需要的朋友可以參考下2018-07-07
用Javascript評估用戶輸入密碼的強(qiáng)度實現(xiàn)代碼
用Javascript評估用戶輸入密碼的強(qiáng)度實現(xiàn)代碼,需要的朋友可以參考下。2011-11-11
JavaScript實現(xiàn)跨瀏覽器的添加及刪除事件綁定函數(shù)實例
這篇文章主要介紹了JavaScript實現(xiàn)跨瀏覽器的添加及刪除事件綁定函數(shù),采用純javascript實現(xiàn)jquery的bind及unbind添加與刪除事件綁定的技巧,具有很好的瀏覽器兼容性,需要的朋友可以參考下2015-08-08

