使用asp提交表單方式直接登錄imail8.1x版本郵箱的代碼分析(原創(chuàng))
來(lái)源:
發(fā)布時(shí)間:2010/8/18
瀏覽次數(shù):1642
經(jīng)常碰到客戶要求直接從網(wǎng)站主頁(yè)登錄到郵箱,而郵箱系統(tǒng)是imail8.1x,經(jīng)過一番修改測(cè)試,成功登錄;8.22版本未試,但應(yīng)該也適用。現(xiàn)將代碼發(fā)布供大家分享:
'實(shí)現(xiàn)登錄檢查及提交表單
<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>
'網(wǎng)頁(yè)上郵箱登錄表單
<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>