⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dom2 mouse events.htm

📁 javascript 核心技术 eval()函数的使用 DOM2 事件模型 非标准事件绑定 图片跟随鼠标 传统文档对象测试
💻 HTM
字号:
<!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.ctrKey;
   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 + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -