求一段H5移动端禁止复制,长按d出菜单html代码。

求一段H5移动端禁止复制,长按d出菜单html代码。,第1张

禁止复制

οncοntextmenu='return false'    //禁止右键

οndragstart='return false'    //禁止拖动

onselectstart ='return false'    //禁止选中

οnselect='document.selection.empty()'    //禁止选中

οncοpy='document.selection.empty()'    //禁止复制

onbeforecopy='return false'   // 禁止复制

οnmοuseup='document.selection.empty()'

*{

  moz-user-select: -moz-none

  -moz-user-select: none

  -o-user-select:none

  -khtml-user-select:none

  -webkit-user-select:none

  -ms-user-select:none

  user-select:none

}

长按事件document.addEventListener("touchstart", function (e) {     console.log('touchstart')     timer = setTimeout(function () {         console.log('LongPress')         e.preventDefault()         LongPress(parentObj)     }, 800) }) document.addEventListener("touchmove", function (e) {     console.log('touchmove')     clearTimeout(timer)     timer = 0 }) document.addEventListener("touchend", function (e) {     console.log('touchend')     clearTimeout(timer)     if (timer != 0) {         alert('这是点击,不是长按')     }     return false })

    pointer-events 主要的用途还是穿透元素,该pointer-events属性允许用户穿过遮罩点击到下面的目标元素。

    在移动端html中,浏览器自带的长摁保存图片功能,及时是让图片作为div的一个背景都会被触发,所以我们可以使用时间穿透,来禁掉长摁保存图片。 pointer-events:none就可以了

pointer-events的其他属性值:


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/7480198.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-04-06
下一篇 2023-04-06

发表评论

登录后才能评论

评论列表(0条)

保存