Jump to content

Get cursor position


MiLLion

Recommended Posts

Hi, i want to find the cursorposition when you click on an image, then i want AJAX to submit to a database...

I've been trying the following:

 

<script language="javascript">
function getDetails(obj){
clickX = window.event.x-obj.offsetLeft;
clickY = window.event.y-obj.offsetTop;
alert('X: ' + clickX + ' Y: ' + clickY + '.');
}
</script> 

 

and

 

<script language="javascript">
var tempX = 0
var tempY = 0
function getDetails(obj){

  if (IE) { // grab the x-y pos.s if browser is IE
    tempX = event.clientX + document.body.scrollLeft
    tempY = event.clientY + document.body.scrollTop
  } else {  // grab the x-y pos.s if browser is NS
    tempX = e.pageX
    tempY = e.pageY
  }  
  // catch possible negative values in NS4
  if (tempX < 0){tempX = 0}
  if (tempY < 0){tempY = 0}  
alert('X: ' + tempX + ' Y: ' + tempY + '.');

}
</script> 

but i don't know how to process it to a database!

 

Any suggestions?

Thanks

Link to comment
https://forums.phpfreaks.com/topic/66770-get-cursor-position/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.