...

View Full Version : absolute x y mouse positions



ghell
08-13-2004, 03:52 PM
i am doing a script where i click on an image and it gets the x and y position of the cursor, i got it all working fine in the system it is part of and stuff apart from that when you scroll across it is clear that the x/y positions are on the broser window, so if i scroll down, it thinks its where it would be if i clicked on the same place without scrolling

is there a different way to get x/y positions than this or a way to make sure it knows where on the pic i have clicked after i have scrolled down

edit: atm i am using

if(document.layers) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = track;

var x, y

function track(e)
{
x = (document.all) ? event.x : e.pageX;
y = (document.all) ? event.y : e.pageY;
}

and an onmouseclick on the image that runs a function with the x&y values

dumpfi
08-13-2004, 04:59 PM
Add this to your x / y coordinates:
IE:
document.body.scrollLeft
document.body.scrollTop
all other:
window.pageXOffset
window.pageYOffset

dumpfi



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum