巫师3支线任务失败:怎样把网页的代码,不让别人在查看中的源代码中随便看啊?需要加上哪些代码????

来源:百度文库 编辑:高校问答 时间:2024/04/27 13:46:06
怎样把网页的代码,不让别人点击“查看”中的源代码中随便看啊?需要加上哪些代码????

1:网页加密代码
<script language=JavaScript>
<!--
var i=0;
var ie=(document.all)?1:0;
var ns=(document.layers)?1:0;

function initStyleElements() /* Styles for Buttons Init */
{
var c = document.pad;
if (ie)
{
//c.text.style.backgroundColor="#DDDDDD";
c.compileIt.style.backgroundColor="#C0C0A8";
c.compileIt.style.cursor="hand";
c.select.style.backgroundColor="#C0C0A8";
c.select.style.cursor="hand";
c.view.style.backgroundColor="#C0C0A8";
c.view.style.cursor="hand";
c.retur.style.backgroundColor="#C0C0A8";
c.retur.style.cursor="hand";
c.clear.style.backgroundColor="#C0C0A8";
c.clear.style.cursor="hand";
}
else return;
}

/* Buttons Enlightment of "Compilation" panel */
function LightOn(what)
{
if (ie) what.style.backgroundColor = '#E0E0D0';
else return;
}
function FocusOn(what)
{
if (ie) what.style.backgroundColor = '#EBEBEB';
else return;
}
function LightOut(what)
{
if (ie) what.style.backgroundColor = '#C0C0A8';
else return;
}
function FocusOff(what)
{
if (ie) what.style.backgroundColor = '#DDDDDD';
else return;
}
/* Buttons Enlightment of "Compilation" panel */

function generate() /* Generation of "Compilation" */
{
code = document.pad.text.value;
if (code)
{
document.pad.text.value='Compiling...Please wait!';
setTimeout("compile()",1000);
}
else alert('请先把需待加密的代码copy到此框中')
}
function compile() /* The "Compilation" */
{
document.pad.text.value='';
compilation=escape(code);
document.pad.text.value="<script>\n<!--\ndocument.write(unescape(\""+compilation+"\"));\n//-->\n<\/script>";
i++;
if (i=1) alert("代码已编译1次!");
else alert("代码已编译"+i+"次!");
}
function selectCode() /* Selecting "Compilation" for Copying */
{
if(document.pad.text.value.length>0)
{
document.pad.text.focus();
document.pad.text.select();
}
else alert('无任何内容被选中!')
}
function preview() /* Preview for the "Compilation" */
{
if(document.pad.text.value.length>0)
{
pr=window.open("","Preview","scrollbars=1,menubar=1,status=1,width=700,height=320,left=50,top=110");
pr.document.write(document.pad.text.value);
}
else alert('无任何内容可供预览!')
}
function uncompile() /* Decompiling a "Compilation" */
{
if (document.pad.text.value.length>0)
{
source=unescape(document.pad.text.value);
document.pad.text.value=""+source+"";
}
else alert('请把需待还原的代码copy到此框中!')
}
// -->
</script>

<table border=0 cellpadding=0 cellspacing=0 width="100%">
<tbody>
<tr>
<td width="100%">
<form method=post name=pad align="center">
<div align="center">
<textarea cols=58 name=textarea rows=11 style="BACKGROUND-COLOR: #ebebeb; WIDTH: 95%">

2网页保密代码
第一步:把如下代码加入到<head>区域中

<SCRIPT language=javascript>

<!--

var Words;

function SetWords(word)

{

Words = escape(word.value);

}

function SetNewWords(form)

{

var NewWords;

NewWords = Words

form.NewWords.value = NewWords;

}

//-->

</SCRIPT>

第二步:把如下代码加入到<body>区域中

<br>
<center>

<table border=5 bordercolor=#000000 borderlight=green>
<tr>

<td align=center width="500"><font size=5 color=red face="Arial, Helvetica, sans-serif"></font></td>

</tr>

<tr>

<td align=center width=500 height=50>

<FORM METHOD="POST">

<div align="center">

<div align="center"> <font color="#999999"><b><font face="楷体_GB2312" size="3">加密页面源代码脚本</font></b></font></div>

<p>将你的页面源代码粘贴在下面的框内,要包括所有的标签例如html , head, body等。</p>

</div>

<P align="center">

<TEXTAREA NAME="Word" VALUE="" ROWS=7 COLS=50 ONCHANGE="SetWords(this)">

下面给几种参考方法,使在浏览我的个人主页时不能使用右键或者不能看到源程序或源代码等。
1)在主页上输入代码:
<SCRIPT language=javascript>
function click() {
if (event.button==2) {
alert('对不起,禁止使用此功能^_^.')
}
}
document.onmousedown=click
</SCRIPT>
<script language="javascript">
<!--
locate = 0;
function scroller() {
if (locate !=500 ) {
locate++;
scroll(0,locate);
clearTimeout(timer);
var timer = setTimeout("scroller()",3);
timer;
}
}
// -->
</script>

思路:

1。在html.asp中用<script src="js.asp"></script>方式来显示内容
2。在html.asp代码中,设置一个session,在js.asp进行判断,如果是设置的值就显示正常内容,如果不是,就隐藏或显示其它内容,在js.asp的结尾把session值改变
3。在html.asp和js.asp中都加一段代码,使得游览器不缓存页面
4。只能做到简单的隐藏,使用工具软件可以看到源文件,如HTTPLook
---------------------------

html.asp程序代码:

<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>查看代码 - www.51windows.Net</title>
<style>
<!--
td { font-family: Tahoma; font-size: 8pt; color: #000080; line-height: 150%;
border: 1 solid #666666; padding: 4 }
-->
</style>
</head>
<body>
<%
session("haiwa") = "hw"
%>
<div align="center">
<center>
<table border="0" cellpadding="0" cellspacing="0" width="480">
<tr>
<td id="tmp"><SCRIPT LANGUAGE="JavaScript" src="js.asp" id="js"></SCRIPT></td>
</tr>
</table>
</center>
</div>
</body>
</html>

-------------------------

js.asp程序代码:

<%
Response.Expires = 0
Response.Expiresabsolute = Now() - 1
Response.AddHeader "pragma","no-cache"
Response.AddHeader "cache-control","private"
Response.CacheControl = "no-cache"
if session("haiwa") <> "hw" then
response.write "//欢迎查看源文件"
response.end
end if
%>
//你能看到源文件你是超级高手
document.write ("随便加一点文字用于演示效果。")
<%
session("haiwa") = ""
%>