zoukankan      html  css  js  c++  java
  • 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")'>

  • 相关阅读:
    让PHP开发者事半功倍的十大技巧
    Sublime Text 3 快捷键总结
    localhost访问错误Forbidden You don't have permission to access / on this server.解决办法(亲测)
    html在一个页面显示另一个页面的部分内容
    db2许可证安装
    spring3中使用注解方式实现定时器调度任务
    c3p0详细设置
    hibernate.cfg.xml详细配置
    ExtJS学习(面板)
    汉诺塔算法
  • 原文地址:https://www.cnblogs.com/RobotTech/p/599098.html
Copyright © 2011-2022 走看看