RSS
热门:  排名  seo

禁止查看源文件的代码

Tag:禁止查看源文件   来源: 作者: 时间:2008-05-06 点击:
如何禁止查看源文件? 有下面几种方式 锁定右键 将网页中的换为如下代码即可:

如何禁止查看源文件?

有下面几种方式

锁定右键

将网页中的<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">


上一篇:没有了
下一篇:mysql字段替换语句的函数
禁止查看源文件的代码的评论共有 0 位网友参与评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
匿名