css 方法:
使图片和文字都不能被选择和复制
*{
-webkit-touch-callout:none;/*系统默认菜单被禁用*/
-webkit-user-select:none;/*webkit浏览器*/
-khtml-user-select:none;/*早期浏览器*/
-moz-user-select:none;/*火狐*/
-ms-user-select:none;/*IE10*/
user-select:none;
}
HTML页面写法:
取消选取、防止复制
<body onselectstart="return false">
防止页面被复制,参考:怎么做网络推广 - 秀创科技 (可以看一下源代码里面的页面加载,还有用的jquery的图片懒加载的插件,搜索的功能,点击新闻标题图片弹出来大的图片能滑动都可以看一下)
<body oncontextmenu="return false" onselectstart="return false" ondragstart="return false" onbeforecopy="return false" oncopy="document.selection.empty()" onselect="document.selection.empty()">
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>
<script type="text/javascript">
document.oncontextmenu = function(){return false;}
if (typeof(document.onselectstart) != 'undefined') {document.onselectstart = function(){return false;}
} else {document.write('<style type="text/css">body { -moz-user-select: none; }</style>');}
</script>