做網站的時候有些內容不希望別人複製,所以就要實現這個功能,實現方法如下:
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;
}
html body標籤
<body οncοntextmenu="return false;" onselectstart="return false">
//前面一句是禁止右鍵,後面一句是禁止複製。
js
//禁止頁面選擇以及鼠標右鍵
document.οncοntextmenu=function(){return false;};
document.onselectstart=function(){return false;};