富贵长生天做主由不得我
钢骨正气我做主由不得天

禁止鼠标右键和选择的两段JS代码

禁止鼠标右键和选择

 <script>     
    function iEsc(){ return false; }  
    function iRec(){ return true; }  
    function DisableKeys() {  
        if(event.ctrlKey || event.shiftKey || event.altKey)  {  
        window.event.returnValue=false;  
        iEsc();}  
    }  
      
    document.ondragstart=iEsc;  
    document.onkeydown=DisableKeys;  
    document.oncontextmenu=iEsc;  
      
    if (typeof document.onselectstart !="undefined") document.onselectstart=iEsc;  
    else  
    {  
        document.onmousedown=iEsc;  
        document.onmouseup=iRec;  
    }  
      
    function DisableRightClick(e)  
    {  
        if (window.Event){ if (e.which == 2 || e.which == 3) iEsc();}  
        else  
            if (event.button == 2 || event.button == 3)  
            {  
                event.cancelBubble = true  
                event.returnValue = false;  
                iEsc();  
            }  
    }  
</script>

禁止右键

		<script type="text/javascript">
			document.oncontextmenu = function(){
				alert("当前页面不能使用右键!");
				return false;
			}
		</script>

赞(0)
未经允许不得转载:网站快照劫持代码-快照删除-黑帽SEO » 禁止鼠标右键和选择的两段JS代码

评论 抢沙发

评论前必须登录!