Forum Moderators: open
Case:
Suppose i had a image ,when mouse is clicked @ certain position of image, then it should alert the x & y coordinate of that point..
Awaiting for your great help..
Thanks in advance to all of you
<img src="....." onClick="getClick(event)">
in FF:
<img id="img" src="......" onClick="javascript:getClick1()">
IE Javascript:
function getClick(event)
{
xcoord=event.clientX;
ycoord=event.clientY;
}
FF Javascript:
var xcoord;
var ycoord;
function getCoords(e)
{
xcoord=e.clientX;
ycoord=e.clientY;
}
function getClick1()
{
.........
}
window.onload=function(){
document.getElementById('img').addEventListener('C lick',getCoords,false);
}
-----------------------------------------------
Unfortunately FF requires an event listener to capture mouse events, whereas IE has one built in. Hopefully you get ther idea, I know there are better ways but this should point you in the right direction.
If the screen res is 800x600 then u won't get and co-ords greater than 800x600. If the res is higher then the co-ords returned will reflect this.
Not sure why the screen res should make any difference to the location of you click, the only diff being the coords returned.