Possible Duplicate:
Mouse position relative to div
getting mouse position with javascript within canvas
How can I get the position of the mouse within a canvas that is a fixed size but has an automatic margin?
I can't make its position fixed and can't just use the regular mouse position on the page.
This code works perfectly:
mouseX = e.pageX - div.offsetLeft;
mouseY = e.pageY - div.offsetTop;