js禁止右擊復制,禁止按CTRL+C復制
易天科技近日接到某網(wǎng)站客戶的要求,發(fā)現(xiàn)其網(wǎng)站內(nèi)的大量原創(chuàng)文章被競爭對手復制。對其造成很大的影響。公司聘請了專業(yè)的法律顧問正在收集證據(jù)對其事件起行了起訴。當務之禁止別人復制。以下是JS的訪法,雖不能徹底禁止別人復制,但從一定角度上增加了復制的復雜程度。對于小白有一定的效果。
JavaScript代碼
- <SCRIPT>
- //js加入頁面保護
- function rf()
- {return false; }
- document.oncontextmenu = rf
- function keydown()
- {if(event.ctrlKey ==true || event.keyCode ==93 || event.shiftKey ==true){return false;} }
- document.onkeydown =keydown
- function drag()
- {return false;}
- document.ondragstart=drag
- function stopmouse(e) {
- if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
- return false;
- else if
- (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
- alert("易天科技提示您,此文章涉及到版權,不能復制轉載 !");
- return false;
- }
- return true;
- }
- document.onmousedown=stopmouse;
- if (document.layers)
- window.captureEvents(Event.MOUSEDOWN);
- window.onmousedown=stopmouse;
- </SCRIPT>
- <script language="javascript">
- function JM_cc(ob){
- var bj=MM_findObj(ob); if (obj) {
- obj.select();js=obj.createTextRange();js.execCommand("Copy");}
- }
- function MM_findObj(n, d) { //v4.0
- var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
- d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
- if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[n];
- for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers.document);
- if(!x && document.getElementById) x=document.getElementById(n); return x;
- }
- </script>