锁定右键及禁止查看源文件
分类:电脑知识 发表于:2010-07-28 09:27:25 评论(2)
锁定右键
<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()">
不准粘贴
onpaste="return false"
防止复制
oncopy="return false;" oncut="return false;"
关闭输入法
<input style="ime-mode:disabled">
拒绝另存
<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.htm" name="mainFrame">
</frameset><noframes></noframes>
</html>
同时主页面index.htm再添如下代码,以防被独立打开:
<script language="javascript"> if(top==self)top.location="index.htm" </script>
防止被别人框架
<SCRIPT language=javascript>
if (top.location != self.location){top.location=self.location; }
</SCRIPT>