锁定右键
一点要锁定右键,这里是为了兼容所有的浏览器,尤其是FF,不然FF可以复制
<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="/*>";</iframe></noscript>
禁止查看源代码
尽管通过以上方式屏蔽了右键查看源文件,拒绝了复制和另存,但通过工具栏的【查看】-【源文件】仍会使网页失锁
要彻底禁止查看源文件,可通过零框架技术解决——将页面分为左右两帧,左帧的宽度为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>
同时,框架分2部分 ,为了防止index.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>
禁止打印
<style>@media print{body{display:none}}</style>
网友评论