• window.event的属性


    <script language="JavaScript" for="document" event="onmousemove">

    document.getElementById("txt_offsetX").value = window.event.offsetX;
    document.getElementById("txt_offsetY").value = window.event.offsetY;

    document.getElementById("txt_screenX").value = window.event.screenX;
    document.getElementById("txt_screenY").value = window.event.screenY;

    document.getElementById("txt_clientX").value = window.event.clientX;
    document.getElementById("txt_clientY").value = window.event.clientY;
    </script>

    <script language="JavaScript" for="document" event="onmousedown">
    alert(window.event.button);
    /*
    语法:
    event.button

    可能的值:
    0 没按键
    1 按左键
    2 按右键
    3 按左右键
    4 按中间键
    5 按左键和中间键
    6 按右键和中间键
    7 按所有的键

    这个属性仅用于onmousedown, onmouseup, 和 onmousemove 事件。对其他事件,不管鼠标状态如何,都返回 0(比如onclick)
    */
    </script>
    <script language="JavaScript" for="document" event="onmouseup">
    alert(window.event.button);

    </script>

    <script language="JavaScript">

    function Show()
    {
     document.getElementById("txt_offsetX").value = window.event.offsetX;
     document.getElementById("txt_offsetY").value = window.event.offsetY;
     alert("event.type:"+window.event.type);
     alert("event.propertyName:"+window.event.propertyName);
     
    }

    function mouse_over()
    {
     alert("onmouseover事件触发\r\n" + "fieldset的id属性:" +window.event.toElement.id);
     //alert(window.event.fromElement.id);
    }

    function mouse_out()
    {
     alert("onmouseout事件触发\r\n" + "fieldset的id属性:" + window.event.fromElement.id);
    }

    </script>

    <SCRIPT LANGUAGE="JScript">
    function cancelLink() {
        if (window.event.srcElement.tagName == "A" && window.event.shiftKey) //屏蔽 Shift+ckick 打开新窗口
            window.event.returnValue = false;
    }
    </SCRIPT>

    <BODY onmousemove="window.status = 'X=' + window.event.x + ' Y=' + window.event.y" onclick="cancelLink()">

    offsetX:<input type="text" id="txt_offsetX">screenX:<input type="text" id="txt_screenX">clientX:<input type="text" id="txt_clientX"><br />
    offsetY:<input type="text" id="txt_offsetY">screenY:<input type="text" id="txt_screenY">clientY:<input type="text" id="txt_clientY"><br />
    <input name="btn" id="btn" type="button" value="显示" onclick="Show()">

    <br>
    <fieldset style="500px;" onmouseover="mouse_over()" onmouseout="mouse_out()" id="fs">
    <legend>测试</legend>
    onmouseover,onmouseout事件 显示该fieldset的id属性
    </fieldset>


    <br />

    <SCRIPT>
    function changeProp()
    {
        btnProp.value = "This is the new VALUE";
    }
    </SCRIPT>


    <INPUT TYPE=button ID=btnProp onclick="changeProp()"
           VALUE="Click to change the VALUE property of this button"
           onpropertychange='alert("["+event.propertyName+"] property has changed value")'>

  • 相关阅读:
    老树新芽,在ES6下使用Express
    Swift3翻天覆地的改变
    NodeJs回调操作Promise化
    Node的关系型数据库ORM库:bookshelf
    基于Node的PetShop,RESTful API以及认证
    基于Node的PetShop,oauth2认证RESTful API
    Mongoose轻松搞定MongoDB,不要回调!
    Thymeleaf常用语法:表达式语法之运算符
    Thymeleaf对象的使用:日期对象
    Thymeleaf对象的使用:字符串对象
  • 原文地址:https://www.cnblogs.com/RobotTech/p/599098.html
Copyright © 2020-2023  润新知