zoukankan      html  css  js  c++  java
  • wap手机端按下 松开 滑动事件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Document</title>
        <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"        name="viewport" /> 
        <script type="text/javascript">
            function a() {
                var mdiv = document.getElementById("mdiv");
                var mdiv2 = document.getElementById("mdiv2");
                var mdiv3 = document.getElementById("mdiv3");
                var m = Math, 
                isTouchPad = (/hp-tablet/gi).test(navigator.appVersion), 
                hasTouch = 'ontouchstart' in window && !isTouchPad,
                START_EV = hasTouch ? 'touchstart' : 'mousedown',
             MOVE_EV = hasTouch ? 'touchmove' : 'mousemove',
             END_EV = hasTouch ? 'touchend' : 'mouseup',
             CANCEL_EV = hasTouch ? 'touchcancel' : 'mouseup';
                mdiv.addEventListener(MOVE_EV, function (e) {
                    var point = hasTouch ? e.touches[0] : e;
                    mdiv3.innerHTML = "X:" + point.pageX + ";Y:" + point.pageY + "";
                }, false);
                mdiv.addEventListener(START_EV, function (e) {
                    var point = hasTouch ? e.touches[0] : e;
                    mdiv2.innerHTML = "BeginX:" + point.pageX + ";BeginY:" + point.pageY + "<br/>";
                }, false);
                mdiv.addEventListener(END_EV, function (e) {
                    var point = hasTouch ? e.changedTouches[0] : e;
                    mdiv2.innerHTML +=( "EndX:" + point.pageX + ";EndY:" + point.pageY + "");
                }, false);
            }
        </script>
    </head>
    <body onload="a()">
    <div style="border: solid 1px #000000; background: #ffffff;  100%; height: 299px; margin:auto" id="mdiv"> 
        <div id="mdiv3"> </div>
        <div id="mdiv2"></div>
    </div>
    </body>
    </html>
  • 相关阅读:
    如何在Altium中下载并添加软件没有的苦文件【转】
    20121124
    变量作用域&函数作用域
    http相关知识
    函数声明和函数表达式
    js中constructor和prototype
    委托模式
    js跨域
    原型和原型链
    javascript 数据类型
  • 原文地址:https://www.cnblogs.com/fanxiaowu/p/4510549.html
Copyright © 2011-2022 走看看