是不是很烦有些人复制你网站内容时不留版权,既然这样,那直接禁止别人复制,下面分享三种代码,一种是禁止选中内容,另一种在别人复制网站内容时,显示温馨提示语.还一种更直接的禁止了所有有关复制功能键的使用!
禁止选中复制内容
div {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
-khtml-user-select: none;
user-select: none;
}
右键复制时显示提示语
把下面代码放到footer.php里即可
<html>
<head><title>防复制</title><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /></head>
<script>
function stop(){
alert('鄙视盗版,尊重版权,人人有责!');
return false;
}
document.oncontextmenu=stop;
</script>
<body onselectstart="return false" onpaste="return false" oncopy="return false;" oncut="return false;" >
</body>
</html>
禁用所有复制功能
把下面代码放到footer.php里即可。
<script type="text/Javascript">
<!--
document.oncontextmenu=function(e){return false;};
document.onselectstart=function(e){return false;};
//-->
</script>
<style>
body{
-moz-user-select:none;
}
</style>
<SCRIPT LANGUAGE=javascript>
<!-- if (top.location != self.location)top.location=self.location; // -->
</SCRIPT>
<noscript><iframe src=*.html></iframe></noscript>
此代码实现:
1、禁止鼠标左键选取内容。
2、禁止鼠标右键复制功能。
3、禁止使用ctrl键,无法复制。