站内搜索:
首页 >> 前端 >> 内容
阻止文章被别人复制粘贴的代码方法

时间:2018/2/11 14:17:18

直接在body 里加上这一段代码

<body onmousemove=/HideMenu()/ oncontextmenu="return false"
ondragstart="return false" onselectstart ="return false" 
onselect="document.selection.empty()" 
oncopy="document.selection.empty()" onbeforecopy="return false" 
onmouseup="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>

  • 上一篇:关于HTML多媒体的详细介绍
  • 下一篇:做列表页时图片不变形的问题阐述
  • 返回顶部