Jquery1.5的版本小bug

来源:互联网 发布:简单网页源码 编辑:程序博客网 时间:2024/04/28 10:55

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.

Jquery1.5的版本,没啥逻辑和语法错误,但是浏览器老报这个错,没时间研究,先放这里,回去再仔细查阅。。


原文:http://www.irideas.com/?p=10

由“event.layerX and event.layerY”说起

 

最近常常在chrome16(360EE5.1)的控制台看到这样的警告

event.layerX and event.layerY are broken and deprecated in WebKit. They will be removed from the engine in the near future.

看着不爽,但这样明白的提示并非不可理解。诱因也是jQuery1.7发布后告知过得

event.layerX and event.layerY: We have removed these non-standard properties in version 1.7. Although we normally would have gone through a deprecation notice period for these, Chrome version 16 generates a flood of console warning messages on the page. Because of this, we decided to remove them immediately. On platforms that still support these properties, they are available through event.originalEvent.layerX and event.originalEvent.layerY.

event.layerX event.layerY 是mozilla特有的,得到鼠标事件发生地相对源元素的偏移,通常是相对于整个document,除非是发生在绝对或相对定位的元素中,则返回相对于该元素的左上方偏移。

W3C规范中是不存在这样的属性,只有clientX/clientY和screenX/screenY是在规范内得(DOM-Level-2-Events)。

  1.  clientX clientY 事件触发时鼠标相对于当前可视窗口的x坐标和y坐标
  2. screenX screenY 事件触发时鼠标相对于屏幕的x坐标和y坐标
  3. pageX pageY 事件触发时鼠标在整个document的x坐标和y坐标
  4. offsetX offsetY 发生事件的地点在触发事件元素的坐标系统中的 x 坐标和 y 坐标
  5. layerX layerY 发生事件的地点在事件源元素的坐标系统中的x坐标和y坐标

下面是一份广为流传的支持表单

 IEFIREFOXOPERACHROMESAFARIclientX / clientYYYYYYpageX / pageYNYYYYoffsetX / offsetYYNYYYlayerX / layerYNYNYYscreenX / screenYYYYYY

显然layerXY即将在chrome17或之后的版本中退出舞台。
关于这些七七八八的坐标如何使用,有时间再来篇实践吧!