<html><head><title>IE与NS都支持的实时读取鼠标位置的例子</title></head>
<body bgcolor="#fef4d9" onmousemove="microsoftMouseMove()">
<SCRIPT LANGUAGE="JavaScript">
if (navigator.appname == 'Netscape')
{
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = netscapeMouseMove;
}
function netscapeMouseMove(e)
{
if (e.screenX != document.form1.x.value && e.screenY != document.form1.y.value)
{
document.form1.x.value = e.screenX;
document.form1.y.value = e.screenY;
}
}
function microsoftMouseMove()
{
if (window.event.x != document.form1.x.value && window.event.y != document.form1.y.value)
{
document.form1.x.value = window.event.x;
document.form1.y.value = window.event.y;
}
}
</SCRIPT><form name="form1">
X: <input type="text" name="x" size="4"><br>
Y: <input type="text" name="y" size="4">
</form>
</body></html>
<body bgcolor="#fef4d9" onmousemove="microsoftMouseMove()">
<SCRIPT LANGUAGE="JavaScript">
if (navigator.appname == 'Netscape')
{
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = netscapeMouseMove;
}
function netscapeMouseMove(e)
{
if (e.screenX != document.form1.x.value && e.screenY != document.form1.y.value)
{
document.form1.x.value = e.screenX;
document.form1.y.value = e.screenY;
}
}
function microsoftMouseMove()
{
if (window.event.x != document.form1.x.value && window.event.y != document.form1.y.value)
{
document.form1.x.value = window.event.x;
document.form1.y.value = window.event.y;
}
}
</SCRIPT><form name="form1">
X: <input type="text" name="x" size="4"><br>
Y: <input type="text" name="y" size="4">
</form>
</body></html>
解决方案 »
- 请教一个关于iframe显示title标题的问题
- 关于Juery.ajax后台接收值问题
- 请问img标签由position:static变成position:absolute的时候怎么设它的left和top属性呢?
- 以下这段代码怎么改成JS文件代码,高手帮忙下,谢谢
- Prototype.js使用问题,控件中有个__VIEWSTATE就不能应用AJAX了
- javascript的动态添加function问题!!!高手进@@@@@@
- 如何跨域获取变量或调用函数?
- 我先学习javascript编程,各位大哥推荐几本好书,和使用的开发工具啊
- 怎么做到在点击一个链接后,一段时间内再点击的话就没用....
- 请教:如何通过javascript自动设置打印参数(打印方向)?
- 问一个正则表达试
- cerry与angle345有明显的倒分嫌疑,并且应该是同一人!!请版主和各网友查实!
x = window.event.x;
y = window.event.y;