js禁止右擊復(fù)制,禁止按CTRL+C復(fù)制
易天科技近日接到某網(wǎng)站客戶的要求,發(fā)現(xiàn)其網(wǎng)站內(nèi)的大量原創(chuàng)文章被競(jìng)爭(zhēng)對(duì)手復(fù)制。對(duì)其造成很大的影響。公司聘請(qǐng)了專業(yè)的法律顧問正在收集證據(jù)對(duì)其事件起行了起訴。當(dāng)務(wù)之禁止別人復(fù)制。以下是JS的訪法,雖不能徹底禁止別人復(fù)制,但從一定角度上增加了復(fù)制的復(fù)雜程度。對(duì)于小白有一定的效果。
JavaScript代碼
- <SCRIPT>
- //js加入頁(yè)面保護(hù)
- 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("易天科技提示您,此文章涉及到版權(quán),不能復(fù)制轉(zhuǎn)載 !");
- 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>