I have a page that collects click events by event.pageX and event.pageY and I want to map those locations to a 600px by 750px box on another page proportionally. Meaning if there were a screenshot of the other page in the box the marking of the click location would show up visually in the same spot.
I know I have ($('body').width(), $('body').height()), (document.body.offSetWidth, document.body.offSetHeight), and (screen.width, screen.height) at my disposal but I'm not quite sure how best to combine these in order to get an accurate ratio.
Currently I'm just using (in sudo code):
x_ratio = 600 / document.body.offSetWidth
y_ratio = 750 / document.body.offSetHeight
new_x_position = event.pageX * x_ratio
new_y_position = event.pageY * y_ratio
and then the marking of click event inside the box is
<div id='click_marker'
style="position: relative; top: new_y_position px; left: new_x_position px;">
</div>
but this doesn't seem to maintain accuracy across browsers and screen sizes. I would like to take a click position in one browser and screen size and be able to accurately map it on any browser and screen size.
How can I consistently and accurately make this calculation?