开发者

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.

Discover Mouse Position Relative to Restored Browser Window

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!

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜