页面 禁止鼠标选择,右键、复制、粘贴 的css 和 js (兼容性好)

方法一:用纯CSS 禁止鼠标点击事件   (兼容 firefox, google chrome, IE9以上浏览器)
<style>

.rules{

    -moz-user-select: none; 

    -webkit-user-select: none; 

    -ms-user-select: none; 

    -khtml-user-select: none; 

    user-select: none;

}

</style>

方法二:用CSS和js  禁止鼠标点击事件   加强浏览器兼容效果!!!
 (样式css和 js一起使用,兼容firefox , google chrome, IE 等浏览器)

<style>

body{-moz-user-select:none;hutia:expression(this.onselectstart=function(){return(false)});}

.rules{

    -moz-user-select: none; 

    -webkit-user-select: none; 

    -ms-user-select: none; 

    -khtml-user-select: none; 

    user-select: none;

}

</style>

<script>

document.body.onselectstart = document.body.ondrag = function(){
return false;
}

</script>



猜你喜欢

转载自blog.csdn.net/weixin_41883384/article/details/80388500