I am trying to get the position of the click when the user click whatever part of the window. I found this code in many tutorials but it seems not to work.
(function( $ ) {
    $( document ).ready(function() {
        $( window ).click(function( e ) {
            var offset = $(this).offset(),
                relativeX = (e.pageX - offset.left),
                relativeY = (e.pageY - offset.top);
                alert("X: " + relativeX + "  Y: " + relativeY);
        });
    });
})( jQuery );
Firefox console tells me "TypeError: offset is undefined" and I don't understand why it does not work.
Which is the right way to retrieve the click position on the window?
 
     
     
     
    