为了可以在您网站首页上或其他页面输入用户名以及密码后直接进入邮箱,您可以参考以下最简化登录页面,并将其溶入您自己的页面中。(注意:适用于 3.5.2.1 及更高版本)
1、HTML格式文件(注意:请将action中的http地址替换为有效路径):
<html>
<title>登录WebMail</title>
<SCRIPT LANGUAGE=javascript>
<!--
function gook() {
f1.pwhidden.value = encode(f1.pwshow.value, parseInt(f1.picnum.value));
f1.submit();
}
function encode(datastr, bassnum) {
var tempstr;
var tchar;
var newdata = "";
for (var i = 0; i < datastr.length; i++)
{
tchar = 65535 + bassnum - datastr.charCodeAt(i);
tchar = tchar.toString();
while(tchar.length < 5)
{
tchar = "0" + tchar;
}
newdata = newdata + tchar;
}
return newdata;
}
//-->
</SCRIPT>
<!--
请用有效路径替换下一行中的http地址
//-->
<form name="f1" method="post" action="http://localhost/webmail/default.asp">
用户名:<input type="text" name="username">
<input type="hidden" name="pwhidden">
<br>
密 码:<input type="password" name="pwshow">
<input type="hidden" name="picnum" value="7652">
</form>
<input type="button" value="提交" onclick="javascript:gook()">
</html>
2、ASP格式文件(注意:请将root.asp中的yourSite变量替换为您服务器上WebMail的URL路径):
<%
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<%
dim yourSite
yourSite = "http://localhost/"
Session("wem") = ""
Session("mail") = ""
Session("tid") = ""
Session("SecEx") = ""
%>
<html>
<SCRIPT LANGUAGE=javascript>
<!--
function gook() {
if (document.getElementById("usernameshow").value == "")
{
alert("用户名不可为空");
document.getElementById("usernameshow").focus();
return ;
}
if (document.getElementById("pwshow").value == "")
{
alert("密码不可为空");
document.getElementById("pwshow").focus();
return ;
}
f1.username.value = document.getElementById("usernameshow").value;
f1.pwhidden.value = encode(document.getElementById("pwshow").value, parseInt(f1.picnum.value));
f1.SecEx.value = document.getElementById("showSecEx").checked;
f1.submit();
}
function encode(datastr, bassnum) {
var tempstr;
var tchar;
var newdata = "";
for (var i = 0; i < datastr.length; i++)
{
tchar = 65535 + bassnum - datastr.charCodeAt(i);
tchar = tchar.toString();
while(tchar.length < 5)
{
tchar = "0" + tchar;
}
newdata = newdata + tchar;
}
return newdata;
}
//-->
</SCRIPT>
</head>
<body>
<form name="f1" method="post" action="<%=yourSite %>default.asp">
<input type="hidden" name="username">
<input type="hidden" name="pwhidden">
<input type="hidden" name="picnum" value="<%=createRnd() %>">
<input type="hidden" name="SecEx">
</form>
用户名:<input type="text" id="usernameshow" name="usernameshow" maxlength="64" class="textbox">
<br>
密 码:<input type="password" id="pwshow" name="pwshow" maxlength="32" class="textbox">
<br>
<input type="checkbox" id="showSecEx" name="showSecEx">增强安全性
<a href="<%=yourSite %>forgetbf.asp?<%=getGRSN() %>">忘记密码</a>
<br><br>
<input class="Bsbttn" type=submit value="确定" onclick="javascript:gook()">
</body>
</html>
<%
function getGRSN()
dim theGRSN
Randomize
theGRSN = Int((9999999 * Rnd) + 1)
getGRSN = "GRSN=" & CStr(theGRSN)
end function
function createRnd()
dim retval
retval = getGRSN()
if Len(retval) > 4 then
retval = Right(retval, 4)
end if
if Left(retval, 1) = "0" then
retval = "5" & Right(retval, 3)
end if
createRnd = retval
end function
function strDecode(sd_Data, sd_bassnum)
dim sd_vChar
dim sd_NewData
dim sd_TempChar
sd_vChar = 1
do
if sd_vChar > Len(sd_Data) then
exit do
end if
sd_TempChar = CLng(Mid(sd_Data, sd_vChar, 5))
sd_TempChar = ChrW(65535 + sd_bassnum - sd_TempChar)
sd_NewData = sd_NewData & sd_TempChar
sd_vChar = sd_vChar + 5
loop
strDecode = sd_NewData
end function
%>
3.打开新窗口
<form name="f1" method="post" action="<%=yourSite %>default.asp">
改为:
<form name="f1" method="post" target="_blank" action="<%=yourSite %>default.asp">
相关文章
星外winwebmail建立FTP进行管理2012-05-23
鼠标点击图片出现另存外代码2012-02-13
flv网页播放器 最漂亮最好用的含代码详解2010-05-26
收藏当前页的a href代码2009-09-20
动易全站搜索代码(包含文章商城图片下载等模块搜索)2009-07-14
能读数据库地址的flash幻灯片广告代码2009-01-05
ASP代码能否加代码验证是输入是否为空,如果为空则不写入数据库2008-12-27