zoukankan      html  css  js  c++  java
  • 判断鼠标按下时在ie/ff下分别是什么键

    注意,在IE浏览器里面,要在body元素里面的东西点,像这段代码就只能在输入框那块点击,而在ff下,可以在整个窗口点击都有效果。
    1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    2  <html xmlns="http://www.w3.org/1999/xhtml">
    3  <head>
    4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    5 <title>这个是标题</title>
    6
    7 </head>
    8
    9 <body onmousedown="judgeMouse(event)">
    10 <!--Continer层开始 -->
    11 <div id="Container">
    12 <form><input id="name" type="text"/></form>
    13 </div>
    14 <!--Container层结束 -->
    15 </body>
    16 <script type="text/javascript">
    17 function JudgeBlur()
    18 {
    19 var obj1 =document.getElementById("name");
    20 obj1.onblur= function(){
    21 alert("失去焦点啦");
    22 }
    23 }
    24 //JudgeBlur函数结束
    25
    26 function judgeMouse(e)
    27 {
    28 if(!window.event)
    29 {
    30 alert("我是火狐浏览器丫。");
    31 switch (e.button)
    32 {
    33 case 0:
    34 alert("左键");
    35 break;
    36 case 1:
    37 alert("中键");
    38 break;
    39 case 2:
    40 alert("右键");
    41 break;
    42 }
    43 }
    44 else
    45 {
    46 alert("ie浏览器你都不认识丫");
    47 switch (e.button)
    48 {
    49 case 1:
    50 alert("左键");
    51 break;
    52 case 4:
    53 alert("中键");
    54 break;
    55 case 2:
    56 alert("右键");
    57 break;
    58 }
    59 }
    60 }
    61 //判断鼠标按键函数结束
    62 </script>
    63 </html>

    ..
  • 相关阅读:
    springboot接口测试
    谷粒学院_day08_课程管理_添加课程之课程发布(后端开发)
    谷粒学院_day03_vue组件
    谷粒学院_day03_vue固定代码抽取
    vue自定义事件
    vue插槽slot
    vue基本语法
    Vue之axios异步通信
    无归岛[HNOI2009]
    仓库建设[ZJOI2007]
  • 原文地址:https://www.cnblogs.com/lanyueer/p/2072495.html
Copyright © 2011-2022 走看看