趣味訪客計數(shù)器設(shè)計兩則(2)_ASP教程
推薦:推薦:ASP初學(xué)者常用源代碼總結(jié)篇1.獲得系統(tǒng)時間: <%=now()%> 2.取得來訪用的IP: <%=request.serverVariables("remote_host")%> 3.獲得系統(tǒng),瀏覽器版本: <script>
3.注意事項:
由于使用了JavaScript語言,因此該方法具有與應(yīng)用平臺的無關(guān)性,可以適用
于Unix、Windows等多種平臺。另外,此計數(shù)器不同于一般意義上的訪客計數(shù)器,專
門用于記錄某一訪客對某一網(wǎng)站的訪問次數(shù)。
二、設(shè)計方法之二:利用ASP技術(shù)制作趣味計數(shù)器
1.設(shè)計思想:
ASP(動態(tài)服務(wù)器主頁)是微軟公司推出的用以取代CGI的新技術(shù),是目前公認(rèn)
的建立Windows NT動態(tài)站點(diǎn)最好的工具。ASP包含在IIS3.0中,它提供了一個在服務(wù)
器端的scripting環(huán)境,在站點(diǎn)服務(wù)器上執(zhí)行,具有簡單、實用、高效等特點(diǎn)。ASP內(nèi)
含五個內(nèi)置的ActiveX服務(wù)器組件,包括:數(shù)據(jù)庫訪問組件(Database Access
component)、文件訪問組件(File Access component)、廣告輪播器組件(Ad
Rotator component)、內(nèi)容鏈接組件(Content Linking component)、瀏覽器信息
組件(Browser Capabilities component).利用文件訪問組件,通過
FileSystemObject對象和 TextStream對象,可以提供讀寫服務(wù)器文件的功能,實現(xiàn)
訪客計數(shù)器功能。
2.源程序count.asp:
| 以下為引用的內(nèi)容: < html > < head > < meta http-equiv="Content-Type" content="text/html; charset=gb2312" > < title >趣味計數(shù)器< /title > < /head > < body > < p > < % dim out countfile=server.mappath("aspcount.txt") '定義一個服務(wù)器組件 set objfile=server.createobject("scripting.filesystemobject") set out=objfile.opentextfile(countfile,1,false,false) ‘讀取數(shù)據(jù) counter=out.readline out.close set objfile=server.createobject("scripting.filesystemobject") set out=objfile.createtextfile(countfile,TRUE,FALSE) ‘暫時瑣定 application.lock ‘訪客次數(shù)加1 counter=counter 1 ‘寫入數(shù)據(jù) out.writeline(counter) ‘解鎖 application.unlock out.close % > < script language="JavaScript" > function countdisp(countvar){ //實現(xiàn)隨機(jī)顯示,不足6位以0補(bǔ)全 var countvar1="000000" countvar; var howFar1=countvar1.length; countvar1=countvar1.substring(howFar1, howFar1-1) var index="" Math.floor(Math.random()*10); if (index=="10"){ index="0"}; for (var icount=0;icount< 6;icount ){ var g=countvar1.substring(icount,icount 1); document.images[icount].src=http://www.yule21.com/info/"http:// localhost/images/" index g ".gif"; } } < /script >< /p > < ! --預(yù)載入圖像數(shù)組-- > 您是第< img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 > < img src=/uploads/allimg/080822/0957231.gif" height=20 width=20 >位訪問者! < script language="JavaScript" > //調(diào)用count()函數(shù), 實現(xiàn)計數(shù)器的動態(tài)圖像顯示 count(counter); < /script > < /body > |
3.注意事項:
該計數(shù)器只能運(yùn)行于Windows環(huán)境,包括Windows NT Server 4.0(須安裝IIS3.0)、Windows NT 4.0(須安裝Peer Web Services)、Windows 95(須安裝Peer Web Services)。ASP文件擴(kuò)展名以.asp表示,可以用常規(guī)的文本編輯器編輯,也可以利用專門的輔助開發(fā)工具InterDev進(jìn)行開發(fā)設(shè)計,而且該文件必須存放于具有執(zhí)行功能的目錄中。
分享:ASP編程中15個非常有用的例子1.如何用Asp判斷你的網(wǎng)站的虛擬物理路徑 答:使用Mappath方法 以下為引用的內(nèi)容: <p align="center"><font size="4
- asp FSO 讀寫文件本文件實現(xiàn)代碼
- asp中isNull、isEmpty和空字符串的區(qū)別
- asp獲取用戶真實IP地址的方法
- asp連接sqlserver數(shù)據(jù)庫實現(xiàn)代碼
- asp中正則表達(dá)式過濾html代碼函數(shù)
- asp中g(shù)et post提交表單區(qū)別
- 網(wǎng)頁模板:ASP內(nèi)建對象Request
- xmlhttp的open方法使用詳解
- ASP的常用的自定義函數(shù)大全
- asp中用for循環(huán)的一個小技巧
- eWebEditor v3.8 列目錄
- ASP無組件分頁實現(xiàn)思路及代碼
- 相關(guān)鏈接:
- 教程說明:
ASP教程-趣味訪客計數(shù)器設(shè)計兩則(2)
。