zoukankan      html  css  js  c++  java
  • 阻止长按复制页面中的内容;zepto中touch中的应用必须先加载event模块之后;

      

     1 <!doctype html>
     2 <html lang="en">
     3 <head>
     4     <meta charset="UTF-8">
     5     <meta id="viewport" name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=yes"/>
     6     <title>Document</title>
     7     <style>
     8         *{margin:0;padding:0;
     9             -webkit-touch-callout:none;
    10             -webkit-touch-callout:none;
    11             -webkit-user-select:none;
    12             -khtml-user-select:none;
    13             -moz-user-select:none;
    14             -ms-user-select:none;
    15             user-select:none;
    16 
    17         }
    18         .div1{background: #f45;width:200px;height:200px}
    19         .delete { display: none; }
    20         ul{list-style: none}
    21         li{height:100px;margin-bottom: 20px;background:#f45;line-height: 100px}
    22         a{background: #00f;display: inline-block;}
    23     </style>
    24 </head>
    25 <body>
    26 
    27 <ul id=items>
    28     <li>List item 1 <a href=" javascript:void(0)" class=delete>DELETE</a></li>
    29     <li>List item 2 <a href=" javascript:void(0)" class=delete>DELETE</a></li>
    30 </ul>
    31 <script src="http://libs.useso.com/js/zepto/1.1.3/zepto.min.js"></script>
    32 <script src="http://4.suancai.sinaapp.com/event.js"></script>
    33 <script src="http://4.suancai.sinaapp.com/touch.js"></script>
    34 <script>
    35     window.ontouchstart = function(e) { e.preventDefault(); };
    36     // show delete buttons on swipe
    37     $('#items li').swipe(function(){
    38         $('.delete').hide();
    39         $('.delete', this).show();
    40     });
    41 
    42     // delete row on tapping delete button
    43     $('.delete').tap(function(){
    44         alert(11)
    45     })
    46     $('.delete').longTap(function(){
    47         $(this).parent('li').remove()
    48     })
    49 </script>
    50 </body>
    51 </html>

    阻止长按复制的事件发生主要由两部分构成;

    1.js方面:

    1     window.ontouchstart = function(e) { e.preventDefault(); };

    2.css方面:

    *{margin:0;padding:0;
                -webkit-touch-callout:none;
                -webkit-touch-callout:none;
                -webkit-user-select:none;
                -khtml-user-select:none;
                -moz-user-select:none;
                -ms-user-select:none;
                user-select:none;
    
            }


    坚持下去就能成功
  • 相关阅读:
    【Delphi】MD5算法(二):应用
    迅雷不能下载FlashPlayer,下载后自动删除,狂汗!!!
    工作笔记1
    GridControl 获取筛选后的数据{笔记}
    Invoke与BeginInvoke[转]
    这几项能力不知道要几年
    你永远不要去做的事1【译】
    window环境变量——心得【转】
    刚做好的网站客服系统,欢迎大家测试
    .Net 2.0里有一个有用的新功能:迭代器
  • 原文地址:https://www.cnblogs.com/suoking/p/5142903.html
Copyright © 2011-2022 走看看