阻止文章被別人複製黏貼

直接在body 里加上這一段代碼

<body οnmοusemοve=/HideMenu()/ οncοntextmenu="return false"

οndragstart="return false" onselectstart ="return false"
οnselect="document.selection.empty()"
οncοpy="document.selection.empty()" onbeforecopy="return false"

οnmοuseup="document.selection.empty()">

禁用鍵盤中的ctrl、alt、shift複製黏貼

document.onkeydown = function(){
    if( event.ctrlKey ){
        return false;
    }
    if ( event.altKey ){
        return false;
    }
    if ( event.shiftKey ){
        return false;
    }
}
禁用鼠標事件
document.onmousedown = function(e){
    if ( e.which == 2 ){// 鼠標滾輪的按下,滾動不觸發
        return false;
    }
    if( e.which==3 ){// 鼠標右鍵
        return false;
    }
}
如果只想單純的禁用鼠標右鍵,和複製粘貼,還可以將它們直接寫到HTML中的body上面;
<body oncontextmenu = "return false" ></body>

<body onselectstart = "return false" ></body>

<body oncopy = "return false" ></body>
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章