好么,当初我发这篇的时候CSDN博客还没有插入代码的编辑项呢是怎么的。
<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>网页加密</title>
<script language="javascript">
function encrypt()
{ // 加密
var SourceCode;
SourceCode=document.F1.S1.value;
//alert(SourceCode);
if(SourceCode=="") { alert("没有可以加密的代码![原始代码]框中没有内容。"); return; }
document.F1.S2.value=encodeURIComponent(SourceCode);
}
function decode()
{ //译码
var DecodeStr;
DecodeStr=document.F1.S2.value;
//alert(DecodeStr);
if(DecodeStr=="") {alert("没有被加密的代码来还原![加密后代码]框中没有内容。"); return; }
document.F1.S1.value=decodeURIComponent(DecodeStr);
}
function exchange()
{
if(document.F1.R1[0].checked) encrypt();
else if(document.F1.R1[1].checked ) decode();
else alert("没选择“加密/解密”按扭");
}
</script>
</head>
<body bgcolor=#CCD6DF>
<h2 align="center"><font color="#000080">encodeURIComponent 网页加密</font></h2>
<form name="F1" action="" target="_blank" οnsubmit="exchange(); return false;">
<div align="center">
<table width="860" id="table1" height="213" bordercolorlight="#C0C0C0" bordercolordark="#808080">
<tr>
<td width="360" height="28">
<p align="center"><b><font color="#000080">原始代码</font></b></td>
<td width="103" height="28"> </td>
<td height="28">
<p align="center"><b><font color="#000080">加密后代码</font></b></td>
</tr>
<tr>
<td width="360"><textarea rows="14" name="S1" cols="50"></textarea></td>
<td width="103">
<p align="center"><input type="radio" name="R1" checked>加密</p>
<p align="center"><input type="radio" name="R1">解密</p>
<p align="center"><input type="submit" value="<-执行->" name="B1"></p>
</td>
<td><textarea rows="14" name="S2" cols="50"></textarea></td>
</tr>
<tr>
<td colspan="3"><br>
<font color="#0000ff"><HTML><br>
<HEAD><br>
<meta http-equiv="Content-Language" content="zh-cn"><br>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312"><br>
<title>加密</title><br>
<script LANGUAGE="Javascript">document.write(unescape("<b><font color="#CC0000">[加密后代码]</font></b>"))</SCRIPT><br>
</HEAD><br>
<BODY><br>
</BODY><br>
</HTML></font><br>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>