javascript - How do I get the absolute position of a mouse click from an onClick event on the body? -



javascript - How do I get the absolute position of a mouse click from an onClick event on the body? -

i trying absolute position (top , left) of mouse click relative browser/body, not parent elements within body.

i have listener bound body, e.pagex , e.pagey giving me position relative div.

note can leverage jquery , yui functions.

code not work correctly:

//getting position function _handleclick(e) { var info = { absx: e.pagex, absy: e.pagey}; _logclickdata(data); } //binding function var methods = { init: function () { $("body").click(_handleclick); } };

according (http://docs.jquery.com/tutorials:mouse_position), should give absolute positions. offsetx/y gives relative position.

edit nov 2013: original "mouse position" link seems broken, the documentation pagex contains illustration utilizes jquery pagex/y. page offset method contains relevant examples.

javascript onclick position absolute

Comments

Popular posts from this blog

iphone - Dismissing a UIAlertView -

c# - Can ProtoBuf-Net deserialize to a flat class? -

javascript - Change element in each JQuery tab to dynamically generated colors -