用户在复制网页中某些文字信息时,当内容附近有图片时,很容易把这些不需要的图片也复制到。
这时我们可以通过CSS设置禁止选中,代码如下:.icon {
-webkit-touch-callout: none; /* iOS Safari */
-webkit-user-select: none; /* Chrome/Safari/Opera */
-khtml-user-select: none; /* Konqueror */
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* Internet Explorer/Edge */
user-select: none; /* Non-prefixed version, currently not supported by any browser */
}
添加禁止代码后,该图片就不能被选中了。
HTML页面内容禁止选择、复制、右键
刚才在一个站点的源代码的的时候发现的,其实原来真的很简单
关键就在οncοntextmenu='return false'
οndragstart='return false'
onselectstart ='return false'
οnselect='document.selection.empty()'
οncοpy='document.selection.empty()'
onbeforecopy='return false'
οnmοuseup='document.selection.empty()'
一个更简单的方法就是在
中加入如下的代码,这样鼠标的左右键都失效了。topmargin="0" οncοntextmenu="return false" οndragstart="return false" onselectstart ="return false" οnselect="document.selection.empty()" οncοpy="document.selection.empty()" onbeforecopy="return false" οnmοuseup="document.selection.empty()"1、禁止网页另存为:在
后面加入以下代码:2、禁止网页内容复制.粘贴:在
中加入以下代码: