相忘于江湖

不抛弃,不放弃... 请给我勇敢,改变可以改变的;请给我坚强,接受不可以改变的;请给我智慧,分辨这两者。

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::

<html>
<head>
<script language="javascript" type="text/javascript">
<!--
var domType = '';
if (document.all) {
 domType = "ie4";
} else if (document.getElementById) {
 domType = "std";
} else if (document.layers) {
 domType = "ns4";
}
function initMouseMove(){
 if(!document.all){
  document.captureEvents(Event.MOUSEMOVE);
 }
 document.onmousemove = mouseMove;
}
function mouseMove(e){
 var x,y;
 if(!document.all){
  fetch_object("txt").value="move";
  x=e.pageX;
  y=e.pageY;
 }else{
  x=document.body.scrollLeft+event.clientX;
  y=document.body.scrollTop+event.clientY;
 }
 fetch_object("txt").value=x+":"+y;
}
var objects=new Array();

function fetch_object(idname, forcefetch) {
 if (forcefetch || typeof(objects[idname]) == "undefined") {
  switch (domType) {
   case "std": {
    objects[idname] = document.getElementById(idname);
   }
   break;

   case "ie4": {
    objects[idname] = document.all[idname];
   }
   break;

   case "ns4": {
    objects[idname] = document.layers[idname];
   }
   break;
  }
 }
 return objects[idname];
}
-->
</script>
<title>get mouse position</title>
</head>
<body onload="initMouseMove()">
<input id="txt"/>
</body>
</html>

posted on 2010-07-16 19:29  playman0211  阅读(170)  评论(0编辑  收藏  举报