JS禁止右键,F12,拖动,复制文本,选中文本......

<body oncontextmenu="return false"禁止鼠标右键 ondragstart="return false;禁止鼠标拖动></body>
<body onselect="document.selection.empty();"禁止复制文本 onselectstart="return false" 禁止鼠标选中文字></body>
document.ondragstart = document.onselectstart = function(){return false;};
document.oncontextmenu = function(){return false};

CSS禁止选中文字

body{
    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;
}

禁止鼠标左右键

<script>
$(function(){
    $('a').mousedown(function(e){
        alert(e.which) // 1 = 鼠标左键; 2 = 鼠标中键; 3 = 鼠标右键
        return false;//阻止链接跳转
    })
})
$('#downwps2010').mousedown(function(e){
    if(3 == e.which){
        alert('这是右键单击事件');
    }else if(2 == e.which){
        alert('这是中键单击事件');
    }else(1 == e.which){
        alert('这是左键单击事件');
    }
})

禁止选中代码

<script>
  document.oncontextmenu=new Function("event.returnValue=false;");
  document.onselectstart=new Function("event.returnValue=false;");
</script>

禁止选择文本

<script>
  var omitformtags=["input", "textarea", "select"]
  omitformtagsomitformtags=omitformtags.join("|")
  function disableselect(e){
    if (omitformtags.indexOf(e.target.tagName.toLowerCase())==-1)
    return false
  }
  function reEnable(){
    return true
  }
    if (typeof document.onselectstart!="undefined")
    document.onselectstart=new Function ("return false")
  else{
    document.onmousedown=disableselect
    document.onmouseup=reEnable
  }
</script>

禁止另存为

<noscript><iframe src="/*.htm"></iframe></noscript>

屏蔽F12审查元素,但是屏蔽不掉“设置-开发者工具”

<script>
function fuckyou(){ 
  window.close();//关闭当前窗口(防抽) 
  window.location="about:blank";//将当前窗口跳转置空白页 
} 
function ck(){ 
  console.profile(); 
  console.profileEnd(); //我们判断一下profiles里面有没有东西,如果有,肯定有人按F12了,没错!! 
  if(console.clear){ 
    console.clear() 
  }
  if(typeof console.profiles =="object"){
    return console.profiles.length > 0;
  } 
} 

function hehe(){
  if((window.console && (console.firebug || console.table && /firebug/i.test(console.table()) )) || (typeof opera == 'object' && typeof opera.postError == 'function' && console.profile.length > 0)){
    fuckyou(); 
} 
  if(typeof console.profiles =="object"&&console.profiles.length > 0){ 
    fuckyou(); 
  }
  } 
  hehe(); 
  window.onresize = function(){ 
  if((window.outerHeight-windows.innerHeight)>200) //判断当前窗口内页高度和窗口高度,如果差值大于200,那么呵呵 fuckyou(); 
}
</script>
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容