我需要在桌面左上角点0:0。
现在,从首页测量鼠标的位置
<h2>
TestPosition</h2>
<table cellpadding="0" id="target" cellspacing="0" width="602" height="500" style="float: left;
margin: 0px; padding: 0px; position: relative; background: url(/content/games/kamikaze2/back.jpg) no-repeat 0 0;">
</table>
<div id="log">
</div>
<script type="text/javascript">
$("#target").mousemove(function (event) {
var thisPosX = $(this).position().left;
var thisPosY = $(this).position().top;
var relX = (event.clientX - thisPosX);
var relY = (event.clientY - thisPosY);
var msg = "Handler for .mousemove() called at ";
msg += relX + ", " + relY;
$("#log").html("<div>" + msg + "</div>");
});
</script>
答案 0 :(得分:1)
没有
function localMouse(event, element)
{
var offset = $(element).offset();
return [event.pageX - offset.left, event.pageY - offset.top];
}