<title>Js获取适时获取鼠标坐标值并显示</title>
<script type="text/javascript">
var getCoordInDocumentExample = function(){
var coords = documentgetElementById("coords");
coordsonmousemove = function(e){
var pointer = getCoordInDocument(e);
var coord = documentgetElementById("coord");
coordinnerHTML = "X,Y=("+pointerx+", "+pointery+")";
}
}
var getCoordInDocument = function(e) {
e = e || windowevent;
var x = epageX || (eclientX +
(documentdocumentElementscrollLeft
|| documentbodyscrollLeft));
var y= epageY || (eclientY +
(documentdocumentElementscrollTop
|| documentbodyscrollTop));
return {'x':x,'y':y};
}
windowonload = function(){
getCoordInDocumentExample();
};
</script>
<div id="coords" style="width:500px;height:200px;background:#F2F1D7;border:2px solid #0066cc;">
请在此移动鼠标。
</div>
<br />
<div id="coord" style="width:500px;border:2px solid #336699;"> </div>
Dim x1 As Integer, y1 As Integer Dim x2 As Integer, y2 As Integer Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then x1 = X: y1 = Y End Sub Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then MeCls MeLine (x1, y1)-(X, Y), , B '显示方框图形 End If End Sub Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) x2 = X: y2 = Y If x1 <> x2 And y1 <> y2 Then ' 如果鼠标移动了 MeCurrentX = 0 MeCurrentY = 0 '打印位置到0,0 Print "起点坐标x=" & x1 & " y=" & y1 Print "终点坐标x=" & x2 & " y=" & y2 End If End Sub
以上就是关于JS 获取屏幕中鼠标的坐标值全部的内容,包括:JS 获取屏幕中鼠标的坐标值、vb怎么获得矩形的坐标、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)