I want to capture x and y coordinates of a user?s click inside a graphic image (relative to its upper left corner) in Netscape 6. Making the graphic an image map would accomplish this, but I want to capture the coordinates without reloading the page.
It's easy in IE 5+, using event.offsetX, but this isn't available in Netscape 6. I used the following alternative in Netscape:
xPosition = event.clientX - (document.getElementById("clickfield").offsetLeft);
yPosition = event.clientY - (document.getElementById("clickfield").offsetTop);
However, this only works if the user doesn?t scroll before clicking. Here?s why:
event.clientY is the click event?s y-offset relative to the *browser* frame. This value is altered when the user scrolls.
document.getElementById("clickfield").offsetTop is the graphic's y-offset relative to the *page*. This value remains unchanged regardless of whether the user has scrolled.
Since the two values I rely on respond differently to scrolling, I only get the correct value if the user has not scrolled.
Points to anyone who can tell me how to do this in Netscape 6, in a manner that works even if the user has scrolled. Please also recommend any resources that provide information on event properties such as event.clientX and others in Netscape 6.