LifeNote
  Try to find something different in your life and then write it down      Java乐园:www.java-bj.cn 资料下载
用window.event对象的属性,总共有四对属性用来取得鼠标位置,分别是:  
  clientX和clientY         screenX和screenY       offsetX和offsetY         x和y  
  一   clientX和clientY  
          设置或接收相对于浏览器窗口客户区的鼠标x、y坐标,客户区不包括窗口滚动条及边框  
          大小(MSDN原文:Sets   or   retrieves   the   x-coordinate/y-coordinate   of   the   mouse    
          pointer's   position   relative   to   the   client   area   of   the   window,   excluding    
          window   decorations   and   scroll   bars.)  
   
          在IE4里,这一对属性只读不可写,IE5及以后版本里则可读可写(MSDN原文:The    
          property   is   read-only   in   Microsoft®   Internet   Explorer   4.0,   and   read/write    
          in   Microsoft®   Internet   Explorer   5   and   later.)  
   
          语法:     event.clientX=[iPos]     event.clientY=[iPos]         iPos应该是一个整数  
   
  二   screenX和screenY  
          设置或接收相对于用户屏幕的鼠标坐标  
   
          在IE4里,这一对属性只读不可写,IE5及以后版本里则可读可写  
   
          语法:     event.screenX=[iSize]     event.screenY=[iSize]         iSize应该是一个整数  
   
  三   offsetX和offsetY  
          设置或接收鼠标指针在鼠标所在的元素上的偏移量  
   
          在IE4里,这一对属性只读不可写,IE5及以后版本里则可读可写  
   
          语法:     event.screenX=[iCoord]     event.screenY=[iCoord]       iCoord应该是一个整数  
   
  四   x和y  
          设置或接收相对于鼠标所在的元素的父元素的坐标(MSDN原文:Sets   or   retrieves  
          the     x-coordinate,   in   pixels,   of   the   mouse   pointer's   position   relative   to    
          the   parent   element.)  
   
          在IE4里,这一对属性只读不可写,IE5及以后版本里则可读可写,但IE5以前的版式本里  
          x和y坐标并不相对于鼠标所在的元素的父元素,只相对于浏览器窗口的客户区  
   
          如果在检测鼠标位置时,鼠标却在浏览器窗口的外面,则x和y都返回-1   
   
posted on 2008-03-27 16:52 LifeNote 阅读(921) 评论(0)  编辑  收藏 所属分类: JavaJavascript

标题  
姓名  
主页
验证码 *  
内容(请不要发表任何与政治相关的内容)  
  登录  使用高级评论  新用户注册  返回页首  恢复上次提交