Discover Mouse Position Relative to Restored Browser Window
How do I discover the mouse position relative to the viewable browser window? If you see screenshot below, I want to determine the co-ordinates of the mouse relative to the viewable area in the browser window whilst hovering over those four thumbnails. As you can see I consider the top left corner of the viewable area as 0, 0. I want the exact mouse position and not the position of the thumbnails and I w开发者_Go百科ant to achieve cross-browser compatibility.
Any help?
Found a solution:
$(document).ready(function () {
$("img.thumbnails").mousemove(function (event) {
//X relative to viewable area
var X = (event.pageX - $(window).scrollLeft());
//Y relative to viewable area
var Y = (event.pageY - $(window).scrollTop());
});
});
Thanks!
精彩评论