how do i determine the mouse location on an image using javascript when mouse is clicked
A:
Is this what you are looking for?
http://www.emanueleferonato.com/2006/09/02/click-image-and-get-coordinates-with-javascript/
geeketteSpeaks
2010-10-15 23:03:23
+1
A:
trimmed version of the solution linked by geeketteSpeaks:
<html>
<head>
<script type="text/javascript">
function getImageCoords(event,img) {
var posX = event.offsetX?(event.offsetX):event.pageX-img.offsetLeft;
var posY = event.offsetY?(event.offsetY):event.pageY-img.offsetTop;
alert("You clicked at: ("+posX+","+posY+")");
}
</script>
</head>
<body>
<img src="image.jpg" onclick="getImageCoords(event,this);">
</body>
</html>
jnpcl
2010-10-15 23:14:30