JS禁止网页被复制以及禁止鼠标右击代码

<script type="text/javascript">
    //禁止鼠标右键
    document.oncontextmenu = function(){
        return false;
    }
    //禁止元素被选中
    if (typeof(document.onselectstart) != 'undefined') {       
        // IE chrome下禁止元素被选中       
        document.onselectstart = function(){
            return false;
        }
    } else {
            // firefox下禁止元素被选中的变通办法       
            document.write('<style type="text/css">body { -moz-user-select: none; }</style>');     
    }
</script> 

猜你喜欢

转载自blog.csdn.net/long5693525/article/details/51085418