css、js实现网页内容“禁止选中,禁止右键,禁止复制粘贴”3种方法

有时候我们有这种需求,需要网站内容禁止被选中,不让复制,鼠标右键也不让用,应该如何实现呢?具体如下:

 

第一种方法:通过css样式

*{
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;
}

 

第二种方法:通过body标签

<body οncοntextmenu="return false;" onselectstart="return false">
//前面一句是禁止右键,后面一句是禁止复制。

 

第三种方法:通过js代码

//禁止页面选择以及鼠标右键
document.οncοntextmenu=function(){return false;};
document.onselectstart=function(){return false;};
    A+
发布日期:2019年09月27日 22:14:26  所属分类:HTML
最后更新时间:2020-08-15 16:22:08
头像
  • ¥ 398.0元
  • 市场价:498.0元
  • ¥ 1999.0元
  • 市场价:2999.0元
  • ¥ 99.0元
  • 市场价:129.0元
  • ¥ 29.0元
  • 市场价:99.0元

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: