onmousemove="adjustCoords(event);"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
function adjustCoords(event)
{
var pos=document.getElementById("pos");
// Use the clientX and clientY properties to get the position of the
// mouse relative to the window. The event object is passed as an
// argument to this function.
var lbl="On Window: " + "(" + event.clientX + "," + event.clientY + ")";
// Calculate the position of the mouse over an element. To do this, subtract
// the position of the element the mouse is over from the mouse position. The
// element's position can be determined from its boxObject.
var offsetX = (event.clientX - event.target.boxObject.x);
var offsetY = (event.clientY - event.target.boxObject.y);
// Assign the offsets to the text of a label.
lbl+=" Relative to: " + event.target.tagName + "(" + offsetX + "," + offsetY + ")";
pos.setAttribute("value",lbl);
}
全站熱搜