css、js实现网页内容禁止选中

网页内容不能选中、复制应该如何实现呢?
通过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 oncontextmenu="return false;" onselectstart="return false">
//前面一句是禁止右键,后面一句是禁止复制。
通过js
//禁止页面选择以及鼠标右键
document.oncontextmenu=function(){return false;}; 
document.onselectstart=function(){return false;};

猜你喜欢

转载自blog.csdn.net/liyuxing6639801/article/details/79954569