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>
posted @ 2016-12-06 10:35  万志远  阅读(2889)  评论(0)    收藏  举报