linux社区爱心援助Linux认证系列教程业界动态站务新闻公司招聘网络学院网址大全LPI专题CISCO专题
设为首页
加入收藏
管理团队
JSP  
JAVA  
PERL  
 您的位置:首页 > 开发语言 > JavaScript >
栏目导栏
  php
  JSP
  ASP
  asp.net
  JAVA
  c/c++/c#
  perl
  JavaScript
  Basic
  Delphi
资料搜索
热门文章
·javascript 时间对象的格式化
·去掉字符串前后的空格
·javascript 事件监听机制
·javascript 事件调用顺序
·js刷新框架子页面的七种方法
·JavaScript:替换字符串
·IE下的JScript编程需注意的内存
·用javascript操作word文档
·Javascript中CTRL+回车提交表单
·JS 获取鼠标位置
·javascript判断Email地址是否有
·Javascript中Select的OnChange
·JS实现的滑动展开与折叠效果
·有分页功能的WEB打印
·Javascript实现窗口最大化的严
最新文章
·使用CSS改变表格边框样式
·为网页添加浮动广告
·判断表单中添加是否数字的JS与
·让浏览器状态栏动起来
·使用Javascript制作行间颜色间
·禁止用右键查看源代码
·网页侦测四法
·制作弹出公告窗口
·为网页添加特效
·网页中取消鼠标右键方法大全
·JavaScript 根据屏幕解析度显示
·如何实现浏览器上的右键菜单
·如何制作浮动广告
·让弹出窗口变得“体贴”一些
·JavaScript技巧:让网页自动穿上
Google
 
JS 获取鼠标位置
[ 作者:  加入时间:2007-10-15 14:31:01  来自:Linux联盟收集整理 ]
<html> aBtLinux联盟
<head> aBtLinux联盟
<script language="javascript" type="text/javascript"> aBtLinux联盟
<!-- aBtLinux联盟
var domType = ''; aBtLinux联盟
if (document.all) { aBtLinux联盟
domType = "ie4"; aBtLinux联盟
} else if (document.getElementById) { aBtLinux联盟
domType = "std"; aBtLinux联盟
} else if (document.layers) { aBtLinux联盟
domType = "ns4"; aBtLinux联盟
} aBtLinux联盟
function initMouseMove(){ aBtLinux联盟
if(!document.all){ aBtLinux联盟
document.captureEvents(Event.MOUSEMOVE); aBtLinux联盟
} aBtLinux联盟
document.onmousemove = mouseMove; aBtLinux联盟
} aBtLinux联盟
function mouseMove(e){ aBtLinux联盟
var x,y; aBtLinux联盟
if(!document.all){ aBtLinux联盟
fetch_object("txt").value="move"; aBtLinux联盟
x=e.pageX; aBtLinux联盟
y=e.pageY; aBtLinux联盟
}else{ aBtLinux联盟
x=document.body.scrollLeft+event.clientX; aBtLinux联盟
y=document.body.scrollTop+event.clientY; aBtLinux联盟
} aBtLinux联盟
fetch_object("txt").value=x+":"+y; aBtLinux联盟
} aBtLinux联盟
var objects=new Array(); aBtLinux联盟
aBtLinux联盟
function fetch_object(idname, forcefetch) { aBtLinux联盟
if (forcefetch || typeof(objects[idname]) == "undefined") { aBtLinux联盟
switch (domType) { aBtLinux联盟
case "std": { aBtLinux联盟
objects[idname] = document.getElementById(idname); aBtLinux联盟
} aBtLinux联盟
break; aBtLinux联盟
aBtLinux联盟
case "ie4": { aBtLinux联盟
objects[idname] = document.all[idname]; aBtLinux联盟
} aBtLinux联盟
break; aBtLinux联盟
aBtLinux联盟
case "ns4": { aBtLinux联盟
objects[idname] = document.layers[idname]; aBtLinux联盟
} aBtLinux联盟
break; aBtLinux联盟
} aBtLinux联盟
} aBtLinux联盟
return objects[idname]; aBtLinux联盟
} aBtLinux联盟
--> aBtLinux联盟
</script> aBtLinux联盟
<title>get mouse position</title> aBtLinux联盟
</head> aBtLinux联盟
<body onload="initMouseMove()"> aBtLinux联盟
<input id="txt"/> aBtLinux联盟
</body> aBtLinux联盟
</html> Linux联盟收集整理 ,转贴请标明原始链接,如有任何疑问欢迎来本站Linux论坛讨论
评论】【加入收藏夹】【 】【打印】【关闭
※ 相关链接
 ·JS+CSS打造可拖动的聊天窗口层  (2007-10-30 14:28:20)
 ·JavaScript 访问 JSF 组件的方法  (2007-10-30 14:18:21)
 ·ASP.NET 2.0如何封装JS和CSS文件为服务器端控件  (2007-10-29 14:13:11)
 ·js刷新框架子页面的七种方法  (2007-10-29 13:50:20)
 ·IE浏览器中一个值得关注的JS问题  (2007-10-29 13:49:46)
 ·常用的网页特殊效果JS代码  (2007-10-29 13:48:25)
 ·限制文本字节数的JS源代码程序  (2007-10-29 13:47:48)
 ·JS来实现浏览器菜单的命令  (2007-10-29 13:46:38)
 ·JS实现鼠标点击复制标题和地址  (2007-10-29 13:46:05)
 ·区分JavaScript,Js,VBScript,ASP  (2007-10-29 13:34:19)