当前位置: 代码迷 >> JavaScript >> 很难解决的有关问题
  详细解决方案

很难解决的有关问题

热度:269   发布时间:2012-02-13 17:20:26.0
很难解决的问题
我用window.event.clientY;去的鼠标位置,但是鼠标滚轮滚动时位置就不准了,很难解决,大家帮帮忙!

------解决方案--------------------
window.event.y用这个
------解决方案--------------------
event.y: Sets or retrieves the y-coordinate, in pixels, of the mouse pointer 's position relative to the parent element.

event.screenY: Sets or retrieves the y-coordinate of the mouse pointer 's position relative to the user 's screen.

event.offsetY: Sets or retrieves the y-coordinate of the mouse pointer 's position relative to the object firing the event.

event.clientY: Sets or retrieves the y-coordinate of the mouse pointer 's position relative to the client area of the window, excluding window decorations and scroll bars.
看看说明,哪个是你需要的。
------解决方案--------------------
window.event.x + document.documentElement.scrollLeft;
window.event.y + document.documentElement.scrollTop;
  相关解决方案