用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 阅读(4383) 评论(1)  编辑  收藏 所属分类: JavaJavascript
Comments

只有注册用户登录后才能发表评论。


网站导航: