RSS
 

禁止右键及查看源代码的方法

07

一些禁止查看源文件的脚本,用在网页中,能起到防止别人复制等效果,但是也可以通过其他办法看到源代码,或是复制里面的内容。下面的方法都是一些基本的 js脚本,简单的用用就行了,真正能防到什么程序,谁也不好说。有句话说的好,真正做的好的页面,就不怕被人仿、复制、看,本来互联网就是个开放的嘛。

锁定右键
将网页中的换为如下代码即可:

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


拒绝另存

在和之间加入如下代码:

<noscript><iframe src="/防止被别人框架~~~~~~~~~~~~~~~
<SCRIPT language=javascript>
if (top.location != self.location){top.location=self.location; }
</SCRIPT>

~~~~~~~~~~~~~~~~~~~~~~~~~~

取消选取、防止复制

<SCRIPT language=JavaScript>
window.ClearEvent=function(){event.cancelBubble=false;var sSrcTagName=event.srcElement.tagName.toLowerCase();
return (sSrcTagName=="textarea" || sSrcTagName=="input" || sSrcTagName=="select");}
window.ClearKey=function(){event.cancelBubble=false;var iKeyCode=event.keyCode;return !(iKeyCode==78 && event.ctrlKey);}
with (window.document){oncontextmenu=onselectstart=ondragstart=window.ClearEvent;onkeydown=window.ClearKey;}
</SCRIPT>
<BODY oncontextmenu=self.event.returnValue=false onselectstart="return false">
<body onselectstart="return false"> 

不准粘贴

onpaste="return false" 

防止复制

oncopy="return false;" oncut="return false;"

关闭输入法

<input style="ime-mode:disabled">

There are no posts related to 禁止右键及查看源代码的方法.

 
 

Leave a Reply