Link to home
Start Free TrialLog in
Avatar of tonelm54
tonelm54

asked on

Mouse position in mm not px

I'm trying to find out the position of the mouse over an image, which I can easily do by taking advantage of mousemove and then then event.clientX and event.clientY however these values seem to be px and not mm.

It is not to use mm in my actual design,  but Im creating a pdf and want to know position many elements on a pdf so I need to know the measurments in mm, not px.

My initial thought was to layout the image as a 1px = 1mm, so if I wanted an A4 image, I would blow display the image as 210px x 297px, however is too small.

My problems with sizing isnt really a problem, as I can solve that at a later date, my issue is detecting the mouse position, so what Ive got soo far is:-
<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>mousemove demo</title>
  <style>
  </style>
  <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
</head>
<body>

<img id="imgPDF" src="01.png" height="297px" width="210px" />

<script>
    $("#imgPDF").mousemove(function( event ) {
      var clientCoords = "( " + event.clientX + ", " + event.clientY + " )";
      document.title = clientCoords;
    });
</script>

</body>
</html>

Open in new window


Any ideas?

Thank you
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial