views:

299

answers:

2

Hello,

Is there a way to get a position/coordinates on mouse click? In example if I have an image in a container and I click on it I want to get coordinates(x,y) in that image? I see only 1 solution to make lots of containers on top of image so small(will be like grid) that when I click it will give containers position in js, but I think page will be so freakin slow because of that. Is there any other solution to this?

A: 

pseudo code (change to your framework):

cX=event.clientX; cY=event.clientY;
dusoft
+1  A: 

Get coords of the image (css: top, left) and coords of the mouse click, and do a little math. :-)

This is pretty easy with a JS library like jQuery or prototype.

Philippe Gerber