禁止鼠标右键与禁止复制功能

document.onselectstart =function() {return   false;}           // 防选择   
document.oncopy        =function() {return   false;}          // 防复制
document.oncut         =function() {return   false;}          // 防剪贴
document.onbeforecopy  =function() {return   false;}
document.ondragstart   =function() {return   false;}          //防拖动
document.oncontextmenu =function() {return   false;}          //防右键
document.onmouseup     =function() {document.selection.empty();} 
document.onselect      =function() {document.selection.empty();}
document.oncopy        =function() {document.selection.empty();} 
document.onmousedown   =function() {if (event.button!==1){alert('禁止操作');}}
document.onkeydown     =function() {alert("禁止操作");event.keyCode=0;event.returnValue=false;}

 

// 屏蔽PrintScreen 

  function   testclip(){ 
  try   { 
  if(clipboardData.getData("Text")||clipboardData.getData("HTML")||clipboardData.getData("URL"))   //检测系统内存 
  { 
  null;          //不为图像则保留内存 
  } 
  } 
  catch(e){ 
  clipboardData.setData("Text","")//清空内存 
  } 
  setTimeout("testclip()",500) 
  } 

 

  testclip();//不停清空剪贴板 

 

  // 禁止打印

 @media print{
body{display:none}
}

 

// 禁止保存

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

 

// 禁用右键

function nocontextmenu(){
    event.cancelBubble = true
    event.returnValue = false;
    return false;
}

function norightclick(e){
    if (window.Event){
    if (e.which == 2 || e.which == 3)
    return false;
    }else if (event.button == 2 || event.button == 3){
    event.cancelBubble = true;
    event.returnValue = false;
    return false;
    }
}
//禁止右键
document.οncοntextmenu=nocontextmenu; // for IE5+
document.οnmοusedοwn=norightclick; // for all others

 

 

 

 

禁用

window.ClearEvent=function(){event.cancelBubble=false;

var sSrcTagName=event.srcElement.tagName.toLowerCase();

return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");}

window.ClearKey=function(){event.cancelBubble=false;var iKeyCode=event.keyCode;return !(iKeyCode==78 && event.ctrlKey);}

with (window.document){οncοntextmenu=onselectstart=οndragstart=window.ClearEvent;οnkeydοwn=window.ClearKey;}

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值