js代码实现禁止选择文字复制黏贴


有时候我们不希望自己辛辛苦苦写的文章被别人直接复制黏贴走,可以在页面中添加一段js代码,这段js代码可以禁止选择文字,禁止复制黏贴和鼠标右键,代码如下:
 
<!doctype html>
 
<html lang="en">
 
<head>
 
<meta charset="UTF-8">
 
<meta name="Generator" content="EditPlus?">
 
<meta name="Author" content="">
 
<meta name="Keywords" content="">
 
<meta name="Description" content="">
 
<title>Document</title>
 
</head>
 
<body>
 
<p><a href="http://www.gerenblog.com">万志远个人博客</p>
 
<script type="text/javascript">
 
document.oncontextmenu=new Function('event.returnValue=false;'); document.onselectstart=new Function('event.returnValue=false;');
 
</script>
 
</body>
 
</html>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM