国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

JavaScript gets mouse coordinates

Mouse coordinates include x coordinates, y coordinates, coordinates relative to the client, coordinates relative to the screen, etc.

In JavaScript, mouse coordinates exist as attributes of the event object.

The properties related to mouse coordinates in the event object are as follows.

QQ截圖20161013101054.png

QQ截圖20161013101100.png

Get the coordinate information of the mouse.

<html>
<head>
<title>獲取鼠標(biāo)的坐標(biāo)信息</title>
</head>
<body>
<div id="demo">點(diǎn)擊這里</div>
<script type="text/javascript">
document.getElementById("demo").onclick=function(e){
    var eve = e || window.event;
    var x = eve.clientX,  // 相對(duì)于客戶端的X坐標(biāo)
        y = eve.clientY,  // 相對(duì)于客戶端的Y坐標(biāo)
        x1 = eve.screenX,  // 相對(duì)于計(jì)算機(jī)屏幕的X坐標(biāo)
        y1 = eve.screenY;  // 相對(duì)于計(jì)算機(jī)屏幕的Y坐標(biāo)
        
    alert(
        "相對(duì)客戶端的坐標(biāo):\n"+
        "x = "+x+"\n"+
        "y = "+y+"\n\n"+
        "相對(duì)屏幕的坐標(biāo):\n"+
        "x = "+x1+"\n"+
        "y = "+y1
    );
}
</script>
</body>
</html>


Continuing Learning
||
<html> <head> <title>獲取鼠標(biāo)的坐標(biāo)信息</title> </head> <body> <div id="demo">點(diǎn)擊這里</div> <script type="text/javascript"> document.getElementById("demo").onclick=function(e){ var eve = e || window.event; var x = eve.clientX, // 相對(duì)于客戶端的X坐標(biāo) y = eve.clientY, // 相對(duì)于客戶端的Y坐標(biāo) x1 = eve.screenX, // 相對(duì)于計(jì)算機(jī)屏幕的X坐標(biāo) y1 = eve.screenY; // 相對(duì)于計(jì)算機(jī)屏幕的Y坐標(biāo) alert( "相對(duì)客戶端的坐標(biāo):\n"+ "x = "+x+"\n"+ "y = "+y+"\n\n"+ "相對(duì)屏幕的坐標(biāo):\n"+ "x = "+x1+"\n"+ "y = "+y1 ); } </script> </body> </html>
submitReset Code