经常碰到客户要求直接从网站主页登录到邮箱,而邮箱系统是imail8.1x,经过一番修改测试,成功登录;8.22版本未试,但应该也适用。现将代码发布供大家分享:
'实现登录检查及提交表单
<SCRIPT language=javascript>
<!--
if (top.location !== self.location) {
top.location=self.location;
}
function window_onload() {
usernameshow.focus();
}
function gook() {
if (usernameshow.value == "")
{
alert("用户名不可为空");
usernameshow.focus();
return ;
}
if (pwshow.value == "")
{
alert("密码不可为空");
pwshow.focus();
return ;
}
f1.saveUser.value = showsaveUser.checked;
f1.username.value = usernameshow.value;
f1.SecEx.value = showSecEx.checked;
f1.pwhidden.value = encode(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>
'网页上邮箱登录表单
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<form name="f1" method="post" action="http://mail.xxxx.com/default.asp" target="_blank">
<input type="hidden" name="username">
<input type="hidden" name="pwhidden">
<input type="hidden" name="picnum" value="<%=createRnd() %>">
<input type="hidden" name="saveUser">
<input type="hidden" name="SecEx">
</form>
<tr>
<td width="16%">邮箱登陆</td>
<td width="14%">用户名</td>
<td width="20%" ><input name="usernameshow" type="text" id="usernameshow" size="10"></td>
<td width="9%">密码</td>
<td width="21%"><input name="pwshow" type="password" id="pwshow" size="10" ></td>
<td width="20%"><input type="submit" name="Submit3" value="登 陆" onClick="javascript:gook()"></td>
</tr>
<% if showaccounts = "" then %>
<input type="hidden" name="showSecEx">
<input type="hidden" name="showsaveUser">
<% else %>
<input type="hidden" name="showSecEx">
<% end if %>
</table>