These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:20 pm Advanced search

Mouse position over tabled canvas

Here you can discuss things related to HTML and the Web in general that do not fit in to other categories.

Mouse position over tabled canvas

Postby misterwoo » Wed Mar 23, 2011 2:34 am

Hi,
I have an HTML canvas in a html table. Depending on the size of the browser the mouseover position (when hovering over the canvas) changes. I would like to be able to find out the offset of the canvas. Is there an element in the mouseover event that I can look at?

I tried susbtracting pageY and pageX with no success.

function handleMouseover(e) {
var posx = e.clientX;
var posy = e.clientY;
var text = posx+";"+posy;

posx=e.screenX-e.pageX;
posy=e.screenY-e.pageY;
text = posx+"/"+posy;
drawEventDisplay(text);
misterwoo
<h6>
 
Posts: 1
Joined: Wed Mar 23, 2011 2:30 am

Re: Mouse position over tabled canvas

Postby zcorpan » Wed Mar 30, 2011 4:23 pm

Maybe you want canvas.offsetTop and canvas.offsetLeft?
zcorpan
<article>
 
Posts: 807
Joined: Tue Feb 06, 2007 8:29 pm
Location: Sweden


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 0 guests