博客园禁止pc端以及手机端选中复制粘贴

pc端禁止选中复制:

在设置中的“页首Html代码”加入:

<script>
   document.body.onselectstart = document.body.ondrag = function(){
       return false;
     }
</script>

即可,如下:

但是,这样设置之后,按f12还是可以进行复制粘贴的,这个时候就需要网页禁用f12,在设置中的“页首Html代码”添加如下代码即可:

document.onkeydown=function (e){
        var currKey=0,evt=e||window.event;
        currKey=evt.keyCode||evt.which||evt.charCode;
        if (currKey == 123) {
            window.event.cancelBubble = true;
            window.event.returnValue = false;
        }
    }

 手机端禁止选中复制:

在“页面定制css代码”中输入如下代码即可:

* {
-webkit-touch-callout:none;
-webkit-user-select:none;
-khtml-user-select:none;
-moz-user-select:none;
-ms-user-select:none;
user-select:none;
}

具体位置如下:

原文地址:https://www.cnblogs.com/gwxppg/p/11217956.html