禁止右键/禁止选择/禁止拖曳清空剪切板

function FixPrototypeForGecko()
{
    HTMLElement.prototype.__defineGetter__("runtimeStyle",element_prototype_get_runtimeStyle);
    window.constructor.prototype.__defineGetter__("event",window_prototype_get_event);
    Event.prototype.__defineGetter__("srcElement",event_prototype_get_srcElement);
}
function element_prototype_get_runtimeStyle()
{
    return this.style;
}
function window_prototype_get_event()
{
    return SearchEvent();
}
function event_prototype_get_srcElement()
{
    return this.target;
}

function SearchEvent()
{
    //IE
    if(document.all)
        return window.event;
    func=SearchEvent.caller;
    while(func!=null)
    {
        var arg0=func.arguments[0];
        if(arg0)
        {
            if(arg0.constructor==Event|| arg0.constructor ==MouseEvent)
                return arg0;
        }
        func=func.caller;
    }
    return null;
}

if(window.addEventListener)
{
    FixPrototypeForGecko();
}

 

 

//***********************禁止右键***************************
if (window.Event)
  document.captureEvents(Event.MOUSEUP);
 
function nocontextmenu()
{
    if(event.cancelBubble)
        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)
  {
   if(event.cancelBubble)
    event.cancelBubble = true
   event.returnValue = false;
   return false;
  }
}

//************************禁止选择***************************
function noSelect()
{
 return false;
}

//************************禁止拖曳***************************
function noDragstart()
{
  return false; 
}

//************************清空剪切板*************************
 function keyDown()
 {
  var iekey = event.keyCode;
  //alert(iekey);
    if(iekey == 42)
    {
    //window.clipboardData.setData('img','')
 
 window.clipboardData.clearData();
    }
 }

 

注释:上面为  disable.js 文件
 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!---------------------http://page.chinahr.com/default/20100302000429_427163_10423/index.aspx-------------------------------!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

</head>
<body><script type="text/javascript">if (typeof(_jtMC) == "function") _jtAE(document.body,"mousedown",_jtMC);if (typeof(_jtPageUnload) == "function") document.body.οnunlοad=_jtPageUnload;</script>
<noscript><iframe src='*.htm'></iframe></noscript>
<script src='http://www.cnblogs.com/commonJs/disable.js'></script>
<SCRIPT language=JavaScript>
  document.oncontextmenu = nocontextmenu;
  document.onmousedown = norightclick;
  document.ondragstart = noDragstart;
  document.onselectstart = noSelect;
  if(document.selection)
    document.onselect = document.selection.empty();
  document.onkeydown = keyDown;
</SCRIPT>  <!-- 禁止右键-->
<script src='http://track.chinahr.com/tracker.js'></script><!-- 访问统计-->

转载于:https://www.cnblogs.com/gagaga/archive/2010/03/04/1678556.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值