屏蔽网页右鍵兼容IE6/7/8/9/10/FireFox,谷歌Chrome

原文:http://www.51xuediannao.com/qd63/index.php/page-2-72-1.html
 
 
<!--屏蔽网页右鍵,适用于IE6,IE7,IE8,FireFox,谷歌Chrome浏览器 开始-->

<script type="text/javascript">
function clickIE4(){
        if (event.button==2){
                return false;
        }//end if
}//end func
 
function clickNS4(e){
        if (document.layers||document.getElementById&&!document.all){
                if (e.which==2||e.which==3){
                        return false;
                }//end if
        }//end if
}//end func
 
function OnDeny(){
        if(event.ctrlKey || event.keyCode==78 && event.ctrlKey || event.altKey || event.altKey && event.keyCode==115){
                return false;
        }//end if
}
 
if (document.layers){
        document.captureEvents(Event.MOUSEDOWN);
        document.onmousedown=clickNS4;
        document.onkeydown=OnDeny();
}else if (document.all&&!document.getElementById){
        document.onmousedown=clickIE4;
        document.onkeydown=OnDeny();
}//end if
 
document.oncontextmenu=new Function("return false");
</script>
<!--屏蔽网页右鍵,适用于IE6,IE7,IE8,FireFox,谷歌Chrome浏览器 结束-->

你可能感兴趣的:(浏览器)