C
Cinquini
Hi
I have a html page where a image is displayed. I'd like to calculate
the offset when a user clicks and drags the mouse on it. I have the
following code below, but it only shows me the coordinates when I
perform a click event.
When I click down the mouse, drag a little and release the button,
nothing happens. Here's the code:
function coord_down(e)
{
x1 = e.offsetX;
y1 = e.offsetY;
//alert('X1,Y1 = ' + x1 + ',' + y1);
}
function coord_move(e)
{
x2 = e.offsetX;
y2 = e.offsetY;
}
function coord_up()
{
alert('X1,Y1 = ' + x1 + ',' + y1 + ' X2,Y2 = ' + x2 + ',' + y2);
}
HTML Code
<img id="Lead2" name="Lead2" style="LEFT:0px; TOP:0px;"
height="242" width="339" align="baseline" border="1"
onMouseDown="coord_down(event);" onMouseMove="coord_move(event);"
onMouseUp="coord_up();" Src="some_image.jpg>
</img>
I only can get coordinates in coord_down() when I uncomment the alert
(...) line. If i dont, I get the same coordidates for the X1,X2 and
Y1,Y2 if a perform a click withou drag on the image.
Can someone help me?
I have a html page where a image is displayed. I'd like to calculate
the offset when a user clicks and drags the mouse on it. I have the
following code below, but it only shows me the coordinates when I
perform a click event.
When I click down the mouse, drag a little and release the button,
nothing happens. Here's the code:
function coord_down(e)
{
x1 = e.offsetX;
y1 = e.offsetY;
//alert('X1,Y1 = ' + x1 + ',' + y1);
}
function coord_move(e)
{
x2 = e.offsetX;
y2 = e.offsetY;
}
function coord_up()
{
alert('X1,Y1 = ' + x1 + ',' + y1 + ' X2,Y2 = ' + x2 + ',' + y2);
}
HTML Code
<img id="Lead2" name="Lead2" style="LEFT:0px; TOP:0px;"
height="242" width="339" align="baseline" border="1"
onMouseDown="coord_down(event);" onMouseMove="coord_move(event);"
onMouseUp="coord_up();" Src="some_image.jpg>
</img>
I only can get coordinates in coord_down() when I uncomment the alert
(...) line. If i dont, I get the same coordidates for the X1,X2 and
Y1,Y2 if a perform a click withou drag on the image.
Can someone help me?