使用JS 禁止别人复制网站文章内容

2016-05-08   点击:   发布者:南京互诺科技
方法一:在编写网页的过程中,我们通过给网页添加以下代码来实现,通过添加以下代码,可以有效防止浏览者按“Ctrl+C”及鼠标右键进行复制操作。

具体代码如下,该代码将在用户复制网页内容时显示“版权所有,禁止复制”的用户提示信息:

<SCRIPT LANGUAGE=javascript>function click() {alert('版权所有,禁止复制') }function click1() {if (event.button==2) {alert('版权所有,禁止复制') }}function CtrlKeyDown(){if (event.ctrlKey) {alert('版权所有,禁止复制') }}document.onkeydown=CtrlKeyDown;document.onselectstart=click;document.onmousedown=click1;</SCRIPT>

 

我们还可以“隐藏”性的禁止复制网页内容操作,可以使用以下代码来实现:

<body onmousemove=HideMenu() oncontextmenu="return false" ondragstart="return false" onselectstart ="return false" onselect="document.selection.empty()" oncopy="document.selection.empty()" onbeforecopy="return false" onmouseup="document.selection.empty()"></body>

window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"1","bdSize":"16"},"share":{},"image":{"viewList":["qzone","tsina","tqq","renren","weixin"],"viewText":"分享到:","viewSize":"16"},"selectShare":{"bdContainerClass":null,"bdSelectMiniList":["qzone","tsina","tqq","renren","weixin"]}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];

相关阅读