Page 1 of 1
how to find the position of coordinate on clicked position ?
Posted: Mon May 21, 2007 5:20 am
by PHPycho
hello forums!!
I am wondering to know -
how to find the position of coordinate on clicked position ? using javascript.
Case:
Suppose i had a image ,when mouse is clicked @ certain position of image, then it should alert the x & y coordinate of that point..
Awaiting for your great help..
Thanks in advance to all of you
Posted: Mon May 21, 2007 5:39 am
by Kieran Huggins
Posted: Mon May 21, 2007 12:39 pm
by califdon
Could you use image slices and an imagemap? Check out:
http://www.ihip.com/
Posted: Tue May 22, 2007 1:18 am
by Kieran Huggins
could use an <input type="image"/> to submit to the server. It reports the x & y of where you clicked the image in the GET/POST request. unfortunately, there's no javascript interface I know of.
Maybe you could embed it in a form with an onsubmit handler that intercepts the POST and cancels it? Not sure if it would work... but it's worth investigating!
Posted: Tue May 22, 2007 3:36 am
by mandar-seo
I think Keiren's advice should work. That seems logical. Creating image will not give you precise location of x and y. Try a bit and you will get it.
With regards,
Mandar Thosar
Posted: Wed May 30, 2007 12:23 am
by PHPycho
knock knock !!
but the clicked coordinates for the same position are different for different resolutions..How to avoid such problems...
thanks in advance to all of you
Awaiting for the valueable help
Posted: Wed May 30, 2007 4:19 pm
by RobertGonzalez
From what I understand the image button only send click coordinates in IE (though I could be wrong).
I did find
this little gem whilst asking my good buddy Google if he knew anything about 'Javascript capture click coordinates'. I am wondeing if that could be useful to you.
Posted: Wed May 30, 2007 4:28 pm
by superdezign
Say what? There are like, a dozen attributes of a mouse click... Somewhere along the line, the math should be able to give you the correct coordinates. It's just.. a lot of trial and error (for me). clientX, clientY, scrollX, scrollY, scrollLeft, scrollTop, layerX, layerY, and a bunch of other ones. Match them up with the image's position, and you should be able to come up with the correct coordinates.... Or, am I misinterpreting the topic?