怎樣用ASP實現郵箱訪問?
您在訪問網站時是否會在有些頁面上見到這種功能---您在可以訪問此網站的同時,還可以查看您免費郵箱中是否有新郵件。這個功能是不是讓您覺得很心動、很神秘呢?下面,我就用ASP來舉個例子讓您知道是如何實現這一功能的。
首先你可以去一些提供免費郵件服務的站點,申請一個賬號然后登錄。在打開郵箱時,請您注意地址欄中的內容?,F在以371為例,你會發現其內容通常是: http://www.371.net/prog/login?user=fighter&pass=mypassword。
其中"fighter"是您的賬號,"mypassword" 是您的密碼。這時我們可以從這里得到3個信息。第1條是我們得到了處理文件的url及文件名:"http://www.371 .net/prog/login";第2條是記錄您賬號的變量名:user;第3條是記錄您密碼的變量名:pass。我們知道這些信息后,就可著手寫html文件和asp文件了。
'/*Html源文件內容如下:*/
<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<title>City Club 首頁</title>
<style type="text/css">
<!--
td { font-size: 9pt}
body { font-size: 9pt}
select { font-size: 9pt}
A {text-decoration: none; color: #003366; font-size: 9pt}
A:hover {text-decoration: underline; color: #FF0000; font-size: 9pt}
-->
</style>
<script language="javascript">
function check(tt) {
if (window.document.form1.selectmail.selectedIndex==0) {
alert("請選擇您的郵箱服務器!")
window.document.form1.selectmail.focus()
return false
}
if (tt.account.value=="") {
alert("帳號不能為空!請填寫。")
tt.account.focus()
return false
}
if (tt.account.value.length<3) {
alert("帳號長度不能小于3位!請填寫。")
tt.account.focus()
return false
}
if (tt.password.value=="") {
alert("密碼不能為空!請填寫。")
tt.password.focus()
return false
}
if (tt.password.value.length<3) {
alert("密碼長度不能小于3位!請填寫。")
tt.password.focus()
return false
}
else
return true
}
</script>
<BODY topmargin=12>
<table border=0 bgcolor=d3d3d3>
<td>
<form action="PostOffice.asp" method=post Onsubmit="return check(this)" name=form1
新聞熱點
疑難解答