移动端H5页面禁止长按保存图片,禁止长按选个文本

AI 摘要

文章介绍移动端H5页面禁止长按操作的两种CSS方案:给图片设置pointer-events:none可阻止长按保存;通过-webkit-touch-callout:none及user-select系列属性(含各浏览器前缀)设为none,可禁止长按选中文本,从而实现页面内容保护。

1.禁止长按保存图片:

pointer-events:none;

2.禁止长按选择文本:

css代码:

-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;

评论