經常碰到客戶要求直接從網站主頁登錄到郵箱,而郵箱系統是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>