`
jojo_java
  • 浏览: 93465 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

禁止查看源文件

    博客分类:
  • UI
阅读更多
【锁定右键】

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

【防止被Frame框架】

<SCRIPT LANGUAGE=javascript> if (top.location != self.location)top.location=self.location; </SCRIPT>

【禁止查看源代码】

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

要彻底禁止查看源文件,可通过零框架技术解决——将页面分为左右两帧,左帧的宽度为0,载入空页面文件。“null.htm”;右帧载入要保护代码的页面,框架面页为index.htm,代码如下:
<html>
<head>
<title>--☆--</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">

【加密源代码】

利用Html Guard等html代码加密软件对网页程序代码进行转换加密变成别人看不懂的乱码。

附录:
防止网站博客文章被非法复制、保存、另存为和查看源代码

1.整篇文章不能点右键、不能区域选择和不能复制。不过能查看源文件和下载该页。代码如下:
<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的参数同样可以应用于表格Table、层Div等。

2.在<body> </body> 之间加入如下语句,则网页无法另存为:
<noscript><iframe src=*></iframe></noscript>
加入上述代码后,当执行“另存为”命令时,会弹出“保存网页时出错”的对话框。

防止通过浏览器菜单“查看源代码”:打开页面后清空数据

<script language="javascript">
function clear(){
Source=document.body.firstChild.data;
document.open();
document.close();
document.title="看不到源代码";
document.body.innerHTML=Source;
}
</script>
<body onload=clear()></body>
这招算是目前网上公布的防止查看源代码的方法中最好的了,当然了,要看还是办法的,比如在地址栏中输入“javascript:alert(document.documentElement.outerHTML); ”就可以查看当前网页的源代码了。
分享到:
评论
4 楼 jojo_java 2010-03-27  
鸟哥哥 写道
jojo_java 写道
鸟哥哥 写道
怎么可能

?什么怎么可能?关于你的那个手机游戏的破解吗?

呵呵,关于网页源码。html代码毕竟要发到客户端的嘛
这个呀,防君子不防小人的
3 楼 鸟哥哥 2010-03-26  
jojo_java 写道
鸟哥哥 写道
怎么可能

?什么怎么可能?关于你的那个手机游戏的破解吗?

呵呵,关于网页源码。html代码毕竟要发到客户端的嘛
2 楼 jojo_java 2010-03-26  
鸟哥哥 写道
怎么可能

?什么怎么可能?关于你的那个手机游戏的破解吗?
1 楼 鸟哥哥 2010-03-24  
怎么可能

相关推荐

Global site tag (gtag.js) - Google Analytics