zoukankan      html  css  js  c++  java
  • JQuery捕获网页鼠标点击和坐标

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
        <style type ="text/css" >
        .main{ background-color:Silver; width :100%; height :200px;}
        </style>
        <script src="js/ui/jquery-1.7.1.min.js" type="text/javascript"></script>
        <script language="javascript" type="text/javascript">
            $(function () {
                $('#form1').live('mousedown', function (e) {
                    //var x = e.originalEvent.x || e.originalEvent.layerX || 0; 
                    //var y = e.originalEvent.y || e.originalEvent.layerY || 0; 
                    var x = e.pageX; //当前鼠标所在的X轴位置
                    var y = e.pageY; //当前鼠标所在的Y轴位置
                    if (e.which == 1)
                        $('#divMain').append('<br/> left click;x:' + x + ',y:' + y);
                    else if (e.which == 2)
                        $('#divMain').append('<br/> middle click;x:' + x + ',y:' + y);
                    else if (e.which == 3)
                        $('#divMain').append('<br/> right click;x:' + x + ',y:' + y);
                });
            });
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div id ="divMain" class ="main" >
               <%=ViewData["list"].ToString().ToDateTime()%>
        </div>
        </form>
    </body>
    </html>
  • 相关阅读:
    PHP (20140519)
    PHP (20140516)
    js(20140517)在JS方法中返回多个值的三种方法
    PHP (20140515)
    PHP (20140514)
    Java内网发送邮件
    每日一“酷”之Cookie
    每日一“酷”之Queue
    每日一“酷”之pprint
    每日一“酷”之copy
  • 原文地址:https://www.cnblogs.com/bingle/p/3091751.html
Copyright © 2011-2022 走看看