如何使网页的文字不能被复制

一、使用css

  给body加上样式:user-select: none;

二、使用js

  document.oncontextmenu=new Function("event.returnValue=false");  //在谷歌、edge等现代浏览器中禁止右键功能

  document.onselectstart=new Function("event.returnValue=false");  //对谷歌、edge等现代浏览器生效

  document.onselectstart = new Function("return false");     //对IE和火狐、edge生效

 

posted @ 2018-07-25 18:37  heroljy  阅读(467)  评论(0编辑  收藏  举报