I get mouse coordinates on some web page and save them.
$("div#container").mousemove( function(e) {
client_x = e.pageX;
client_y = e.pageY;
// save x,y
});
Now other person load that same page and i want to show them the same coordinates (x,x position).
How can I get the same point if I have to take in consideration that the div#container is not at same position as it was in my browser (considering screen resolution and scroll)?
This doesn’t seem possible because of the variables you mentioned in the question. Screen resolution is the main reason, but, also, it depends on how big their window is. At first, you might think that you could compute the mouse’s position relative to fixed points, like
divs shown (take Stack Overflow, for example, where the main container of the site doesn’t resize with the browser window). But if their window is smaller than the container, you would be making some false assumptions about what they see.That being said, you can always just compute the mouse position relative to fixed elements you know will be on the screenusing
$.offset()and just assume they have their screen showing everything (or check$(window)size) and are using “normal” viewing conditions.