Log in

View Full Version : mouseOver ImageCoordinates



markmil2002
11-24-2007, 02:39 AM
It seems so simple, and I thought I would be able to find help on the net, but it appears that I am wrong. I have an image and when the mouse is over the area coordinates I want it to show the x and y coordinates for that image in a div tag.

jscheuer1
11-24-2007, 05:59 AM
when the mouse is over the area coordinates

What area coordinates? Is this an image map, or are you speaking in generic, rather than technical terms?

markmil2002
11-25-2007, 11:23 PM
it's an image map.

Kenny
11-26-2007, 01:46 AM
I have a compact script I use while editing with IE. No sense having it cross browser when it's only a local utility. Just paste the stuff in the page you're editing and take it out when you're done. You'll have to tweak it a bit to make it work over your specific div...


<script type="text/javascript">
document.onmousemove = Kcur;
function Kcur() {
X=event.clientX+document.body.scrollLeft;
Y=event.clientY+document.body.scrollTop;
kxy.innerHTML=" Top="+Y+"<br> Left="+X+"";
kxy.style.pixelTop=Y;kxy.style.pixelLeft=X;
return true;
}
</script>
<div id="kxy" style="border:1px inset ;position:absolute;padding:2px;font-family:fixedsys;"> </div>

jscheuer1
11-26-2007, 07:05 AM
I have a compact script I use while editing with IE. No sense having it cross browser when it's only a local utility. Just paste the stuff in the page you're editing and take it out when you're done. You'll have to tweak it a bit to make it work over your specific div...

That might do the trick here, but that would be up to markmil2002 to decide.

Personally, I'm still not clear on what is wanted here or why. The why isn't so important, except that it would help me a lot with the how. The what is important. Do you want this for the live page, or as Kenny is offering, only as a diagnostic tool? If for a live page, it would need to be cross browser, and probably only active while over specific area tags. Do you want the actual mouse coords relative to the page, the coords of the area tag, or the coords of the mouse relative to the image with the top left edge of the image being 0, 0? If Kenny's idea doesn't 'do it' for you, please be more specific as to what is required and why.