阻止长按复制页面中的内容;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;

        }

 



转载于:https://www.cnblogs.com/suoking/p/5142903.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值