|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
ASP最大的缺点在于网络的安全性和可靠性,企业将经营数据放在开放的平台上,最大的担忧就是如何保证这些数据不被其他人破坏。告白byManoharKamath
August9,1999
Creatingaadvertisementrotatorpageiseasy-ASPcomeswithanAdrotatorcomponentthatseasytouse.
Thecomponent,calledAdRotator,isinstalledwhenyouinstallASP.ThecomponenthasbeenapartofASP
installationsincethefirstversionofASP.
Thereare3partstotheadrotatorsystem:
Adrotatorlogicpage
Adimagesdatefile
Redirectionpage
Adrotatorlogicpage
Createafilesayads.inc,anincludefilethatcanbeincludedonanyASPpageonyoursite.Thisfile
willactually"create"theimagelinksontheASPpages.Thepagemakesuseofthefileinitem2,thead
imagesdatafiletochoosetheimagefromthelistofimages.
Thecodeisasshownbelow.IcreatedafunctiongetAd()sothatthisfunctioncanbecalledwithinany
ASPpagewhereyouwantthebannerstoshowup.Theadvantageofputtingthelogicinthefunctionis
obvious-reuseabilityofcode.
<SCRIPTLANGUAGE=VBScriptRUNAT=SERVER>
FunctiongetAd()
DimloAd
CreateaninstanceoftheAdrotatorcomponent
SetloAd=Server.CreateObject("MSWC.AdRotator")
Setthetargetframe,ifany.Thisistheframethewheread
URLwillopenup.IftheHTMLpagedoesnotfindthetargetname
theURLwillbeopenedinanewwindow
loAd.TargetFrame="TARGET=new"
Getarandomavertisementfromthetextfile
Thisfileisinthe/adfolder
getAd=loAd.GetAdvertisement("/ad/adrotator.txt")
EndFunction
</SCRIPT>
Adimagesdatafile
createtheadinformationfile,sayadrotator.txt.Thisfilehastwoparts
Generalinformationforalltheimages-thisinformationisappliedtoallimagesthatarerotated.This
sectioncontains4parts
REDIRECT-thepagethatwillhandletheredirects.youcanspecifyaabsoluteorarelativeURLforthis
page
WIDTH-Widthoftheimages.Ifnotspecified,defaultsto60
HEIGHT-Heightofimages.Ifnotspecified,defaultsto440
BORDERoftheimage.Ifnotspecified,defaultsto1
Individualimageinformation.Thissectionisseparatedfromthefirstbyasingle"*"onaseparateline
asshowninthecodebelow.Thissectionhasfourparts
Imagesource-eitherabsolute,relativeoraURLlikehttp://...
RedirectURL-theURLtobesentwhentheuserclicksontheimage
Alternatetext-Abriefdescriptionoftheadthatappearsintextbrowsers,orwhentheimagesare
turnedoff
Adweight-anumberbetween0and4,294,967,295thatdeterminesthefrequencyofthataddisplay.A
weightof0meanstheadwillneverbedisplayed.Higherthenumber,morefrequentthedisplayis.
E.g.Intheexamplebelow,theweightsoftwoimagesare2and3.So,thesecondimageis3timesmore
likelytoappearforevery2appearanceoffirst.
Assumingtheimagesareinthe/imagesdirectory,asampleadrotator.txtfileisshownbelow.The*
separatesthegeneraldatafromtheimageinfo.Withintheimagesinfo,leaveablanklinebetweeneach
imagedata.
REDIRECTadredir.asp
WIDTH468
HEIGHT60
BORDER0
*
/images/fp2000.gif
http://www.microsoft.com/frontpage
MicrosoftFrontPage2000
2
/images/office2000.gif
http://www.microsoft.com/office
Office2000
3
Redirectionpage
Theredirectionpage,receivesinitsquerystring,avariablenamedURLthatcontainstheURLtoredirect
to,andanothervariableIMAGEthatcontainstheimageURLoftheadimage.TheIMAGEvariableismorefor
statisticalpurposes,tokeepcountofwhatimageappearedwhenandhowmanytimesetc.So,ifyouwereto
keepcountofwhatimageswereclicked,youwouldlogthisintoadatabase(therearebetterways,but
justtryingtoillustratewhythevariableispassed).
Asimpleredirectpage,adredir.asp,isasfollows.ItessentiallyretrievestheURLfromthequerystring
anddoesaResponse.Redirecttoit.
<%@language=VBScript%>
<%
Settheresponsebufferon
Response.Buffer=True
DimlsURL
ObtaintheURLfromthequerystring
lsURL=Request.QueryString("URL")
CleartheresponseandredirecttoURL
Response.Clear()
Response.Redirect(lsURL)
%>
Usingthesystem
Includethefileads.inconanyA</p>我想详细了解ASP整站代码与PSP整站代码有什么优缺点,那个更好,更安全,更用容易维护,和管理。。。 |
|