禁止查看源文件

商帝国咨询头像

阅读 10564 | 分类:文章

锁定右键

将网页中的<body>换为如下代码即可:

<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()">


拒绝另存

在<body>和</body>之间加入如下代码:

<noscript><iframe src="/*>";</iframe></noscript>

禁止查看源代码


尽管通过以上方式屏蔽了右键查看源文件,拒绝了复制和另存,但通过工具栏的【查看】à【源文件】仍会使网页失锁!


要彻底禁止查看源文件,可通过零框架技术解决——将页面分为左右两帧,左帧的宽度为0,载入空页面文件“ null.htm ”;右帧载入要保护代码的页面,框架面页为index.htm,代码如下:

<html>
<head> <title>欢迎光临--☆--CCE教育社区--☆--</title> </head>
<frameset cols="0,*" frameborder="NO" border="0" framespacing="0">
   <frame src="/null.htm" name="leftFrame" scrolling="NO" noresize>
   <frame src="/index.html" name="mainFrame">
</frameset><noframes></noframes>
</html>

同时,已被锁定右键、禁止另存的主面页(原代码见上)命名为 “index.html”,再添如下代码,以防被独立打开:<script language="javascript"> if(top==self)top.location="index.html" </script>

***//防止被别人框架~~~~~~~~~~~~~~~
<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">

留言区(共0条)

暂无留言,快来抢占沙发~
作者声明:非原创
平台声明:文章及评论仅代表作者本人观点,五略商书系信息发布平台,仅提供信息存储空间服务,如有侵权,请联系13521509118。转载请注明作者和出处:转自五略商书m.shangdiguo.com,作者商帝国咨询!