[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Mouse position in mm not px

Posted on 2013-10-29
3
Medium Priority
?
247 Views
Last Modified: 2013-11-13
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
0
Comment
Question by:tonelm54
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 44

Accepted Solution

by:
Chris Stanyon earned 668 total points
ID: 39609402
I think you'll struggle with this as there is no correlation between mm and px. If a 900px wide image is printed at a resolution of 300dpi then you image is likely to be 3 inches wide (about 75mm). If the same image is printed at 200dpi then your image will be output at 4.5 inches (112mm)
0
 
LVL 43

Assisted Solution

by:Rob
Rob earned 1332 total points
ID: 39615980
Adding to what Chris has said, mm means nothing in the digital world so there is no formula on converting px to mm because you can transpose px to whatever mm you like and output to any media (screen or print).

Really would love to say there is an answer to this but unfortunately there just isn't a way unless you fix the variables.

The variables are you physical viewable screen size in mm and your screen resolution in px.  If you know these then you can get a reasonably approximate of px to mm.

make sense?
0
 
LVL 43

Assisted Solution

by:Rob
Rob earned 1332 total points
ID: 39615982
You'll be able to detect the user's screen resolution but they would have to input the viewable physical dimensions of their screen before this would work.  As far as i know you can't detect it.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question