9.14.htm

来自「这是我卖的书上的源码 这书是电子邮电出版的是有关网络编程 有详细的例子」· HTM 代码 · 共 55 行

HTM
55
字号
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>DOM2 Mouse Events</title>
<meta http-equiv="content-type" content="text/html; charset=gb2312">
</head>
<body>
<h2>DOM2 鼠标事件	</h2>
<form id="mouseform" name="mouseform" action="#" method="get">
Alt Key down? 
<input id="altkey" type="text"><br>
Control Key down? 
<input id="controlkey" type="text"><br>

Meta Key down? 
<input id="metakey" type="text"><br>
Shift Key down? 
<input id="shiftkey" type="text"><br>

在浏览器中的按键位置: <input id="clientx" type="text">, 
                              <input id="clienty" type="text"> <br>
在屏幕上的按键位置: <input id="screenx" type="text">, 
                             <input id="screeny" type="text"> <br>
使用的按键: <input id="buttonused" type="text"><br><br>
</form>
<hr>
在文档的任意位置按下鼠标...
<script type="text/javascript">
<!--
function showMouseDetails(event) 
{
  var theForm = document.mouseform;

  theForm.altkey.value = event.altKey;
  theForm.controlkey.value = event.ctrlKey;
  theForm.shiftkey.value = event.shiftKey;
  theForm.metakey.value = event.metaKey;
  theForm.clientx.value = event.clientX;
  theForm.clienty.value = event.clientY;
  theForm.screenx.value = event.screenX;
  theForm.screeny.value = event.screenY;
  if (event.button == 0)
    theForm.buttonused.value = "left";
  else if (event.button ==  1)
    theForm.buttonused.value = "middle";
  else
    theForm.buttonused.value = "right";
}
document.addEventListener("click", showMouseDetails, true);
//-->
</script>
</body>
</html>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?