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

一、使用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生效

猜你喜欢

转载自www.cnblogs.com/heroljy/p/9367653.html
今日推荐