Jump to content

Not sure where to post this or even what it's specifically called...


Jim R

Recommended Posts

It might be called object mapping, but I'm not sure.  Basically, I'm wanting somewhat of a GUI where the User clicks on an area of the page, and the location of the click is noted (for a database).  From there it can be given a value based on whether or not a right click was used vs a left click.

Here's something to get you started i'd use onmouseclick

 

<html>

<head>

<title>Get Mouse Coordinates</title>

<script language=”javascript”>

var divObj;

 

/**

* capture mousemove event, this statement will cause browser to

* call getMouseCoordites function each time mouse moves

*/

document.onmousemove=getMouseCoordinates;

 

/**

*identify which event is supported

* Based on that collect pageX and pageY properties of the event object

* pageX and pageY gets the X and Y cursor coordinates

*/

function getMouseCoordinates(event)

{

ev = event || window.event;

divObj.innerHTML = “Mouse X:”+ev.pageX + ” Mouse Y:”+ev.pageY;

}

 

//assign the mouseCoord Object to divObj

function loadDiv()

{

divObj = document.getElementById(“mouseCoord”);

}

</script>

</head>

 

<body onLoad=”loadDiv()”>

<div id=”mouseCoord”>Mouse Coordinates position will be displayed here.

</div>

</body>

</html>

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.