ASP横幅广告系统外文翻译.doc

上传人:仙人指路1688 文档编号:3894010 上传时间:2023-03-26 格式:DOC 页数:10 大小:58KB
返回 下载 相关 举报
ASP横幅广告系统外文翻译.doc_第1页
第1页 / 共10页
ASP横幅广告系统外文翻译.doc_第2页
第2页 / 共10页
ASP横幅广告系统外文翻译.doc_第3页
第3页 / 共10页
ASP横幅广告系统外文翻译.doc_第4页
第4页 / 共10页
ASP横幅广告系统外文翻译.doc_第5页
第5页 / 共10页
点击查看更多>>
资源描述

《ASP横幅广告系统外文翻译.doc》由会员分享,可在线阅读,更多相关《ASP横幅广告系统外文翻译.doc(10页珍藏版)》请在三一办公上搜索。

1、ASP Banner Ad SystemTo the Reader from Joe:This is a user-submitted tutorial by the author above. I have read the tutorial and set the format to fit HTML Goodies, but for the most part have not changed the language. I chose this tutorial because many readers have been asking for more ASP tutorials.

2、This is a great one.Sorry I cannot show you the event here. The HTML Goodies servers do not offer ASP. I will tell you though that if you run IE5.0 or better, open the contents of the zip file into a directory and it runs just fine.If you havent already, you may want to read my introductoryASP tutor

3、ialbefore this one. If not, then enjoy. There may be a point in your web design career, where your site becomes real popular. That is when companies become interested in advertising on your site. A Banner Ad system can be built to control all those advertisements that you are so willing to display,

4、for a price. Active Server Pages makes it very easy to create a banner ad system. So easy, that the Microsoft ASP developers created an AdRotator component for the occasion. Before you begin reading this article, make sure you download the support material below.The files included aread.txtbanner.as

5、p3 banner imagesclicks.aspexample.aspredirect.aspad.txtIn order for the AdRotator component to work, you must configure a text file. This text file contains all the banner ad properties. However, The text file must follow a certain format. The first four lines are as follows:REDIRECT redirect.aspWID

6、TH 400HEIGHT 50*REDIRECTWhen a banner is clicked, the AdRotator component goes to a preliminary page. This page is called a redirect page. The redirect page handles any extra programming events before directing a user to the banners destination. In this example banner system, I called the preliminar

7、y file redirect.asp.WIDTHThis sets the width of the banner ad image. The value must be in pixels.HEIGHTThis sets the height of the banner ad image. The value must be in pixels.*The asterisk tells the AdRotator component that it is about to acquire banner ad information. The asterisk is required.Once

8、 you define the general properties above the asterisk, then comes the list of banners to display. In thead.txtfile, there are three banners defined below the asterisk.banner1.jpgHTMLG20banner2.jpgY30banner3.jpgD30Each banner requires four lines of properties, which follow the format below:Image file

9、nameWeb Address DescriptionBanner WeightImage FileThe image filename can be a fully qualified web address or relative name that points to the image. If the image is in a different folder, then you also include the folder name as well.( banner1.jpg, or foldername/banner.jpg)Web AddressThe web address

10、 can be a page on your site or a fully qualified web address that leads to another site.DescriptionThe description will be displayed as a tool tip. When you rest your mouse over the banner, the description pops up.Banner WeightThe banner weight determines how much a banner is displayed. The AdRotato

11、r component adds all of the banner weights and determines the probability or percent chance of a particular banner being displayed. A banner with a higher weight has better a better probability.NOTE:You can disable a banners property by substituting with a dash.banner3.jpg-D30The example entry above

12、 would create a banner ad that does not have a web address.Banner.aspThis file uses the AdRotator component and analyzes the contents of the ad.txt file. Below is the code.sub banner(strTarget)dim bannerad, htmlset bannerad = server.CreateObject(MSWC.adrotator)bannerad.TargetFrame = strTargethtml =

13、bannerad.GetAdvertisement(ad.txt)Response.Write htmlend subThe first thing to note is that the ASP was written with VBScript. The second thing to note is that the code is written inside a sub procedure calledbanner(strTarget).For those of you who do not know, a sub procedure allows you to group toge

14、ther a bunch of code that can be reused over and over. Like a function, it takes an argument, such as a word or variable. In the code above the argument is strTarget.Unlike a function, a sub-procedure does not return any values, it just executes the code inside line by line.Inside the sub I declare

15、two variables.dim bannerad, htmlNext I store the AdRotator component inside the bannerad variable. When storing a component inside a variable you use the set keyword. Since we are programming server-side with ASP, we use server.CreateObject to summon the component. MSWC.adrotator is the component ke

16、y or name value.set bannerad = server.CreateObject(MSWC.adrotator)Next I use a property of the AdRotator called TargetFrame. This property is equivalent to:The target-value can be one of the values below:_blankOpens the destination link in a new browser window._topOpens the destination link on top o

17、f the web page._parentOpens the destination link within a parent frame._newOpens the destination link in a new browser window.Next, I use an AdRotator method or function called GetAdvertisement and stored its results in the html variable. Notice that the GetAdvertisement takes the name of the ad ban

18、ner text file as an argument.html = bannerad.GetAdvertisement(ad.txt)Finally, I want to print the contents of the html variable. This prints the code that displays the banner images.Response.Write htmlRedirect.aspThis is the file that is processed before someone is redirected to the banners web addr

19、ess. Inside this file, we can capture information like how many times a particular banner is clicked and so on. To start things off, I defined a variable called strUrl.Dim strUrlNext I store a querystring value inside this new variable.strUrl = Request.Querystring(url)A querystring is nothing more t

20、han a bunch of name/value pairs attached to a web address. When a user clicks on a banner, the AdRotator component attaches a querystring to the redirect file. So if we were to click banner1.jpg, defined in ad.txt, we would end up with a redirect web address that looks like so.Redirect.asp?url=&imag

21、e=banner1.jpgIn essence assigning Request.Querystring(url) to strUrl, is the same as assigning to it.Finally, I check to see which banner was clicked. I accomplish this with the VBSCript inStr( ) function.if instr(strUrl, htmlgoodies) then Application.Lockapplication(htmlgoodies) = application(htmlg

22、oodies) + 1Application.UnLockResponse.ClearResponse.Redirect strUrlend ifThe inStr( ) function returns the number position of a sub-word (sub-string) within another word (string). The format is as followsInStr(main word, sub-word)If the sub-word exist within the main word, then the function will equ

23、al a number greater-than zero or true. If the sub-word does not exist, then the function will equal zero or false. In the example above, I check to see if htmlgoodies exist within . Since the answer is true, then the code inside the if. then. statement will execute.Inside the if. then. I use an appl

24、ication variable. An application variable is native to ASP. Application variables store information as long as a web application exist, a web application ceases to exist when say someone shuts off the web hosting server. The beauty of an application variable is that you can define it on one web page

25、 and use it in other web pages within your web application. The downfall is that the users computer must have cookies enabled.Anyways, the code adds one to the application variable, every time a banner is clicked. After one is added, the code redirects to the banners web page. So if banner1 was clic

26、ked then you shall be redirected to .Response.Redirect strUrlExample.aspThis is an example page that uses the banner ad system. When you refresh the page, you should most likely see a different banner. Whenever you want to insert the banner ad on a page, you can use the SSI directive below.Once you

27、include the file above, then you can call the sub-procedure inside the banner.asp file like so.Call banner(_blank)Notice that I supply one of the values for the TargetFrame as an argument. So if the banner is clicked, then the web page should open up in a separate browser window.Clicks.aspThis is a

28、very simple page that displays the number of clicks per banner ad. To display the number of times a banner was clicked, you just print the contents of the application variables that were created inside redirect.asp. Pretty nifty.ASP横幅广告系统乔给读者的话:这是一个由用户提交上述笔者的教程。我已经阅读教程和设置格式,以适应的HTML超值,但大部分都没有改变的语言。我

29、选择了这个教程,因为很多读者已经要求更多的ASP教程。这是一个伟大的。对不起,我不能告诉你这里的事件。服务器的HTML超值不提供的ASP。我会告诉你,不过,如果你运行的IE5.0或更高,打开zip文件的内容到一个目录,它运行得很好。如果你还没有,你可能会想读这之前我介绍的ASP教程。如果没有,那么享受。可能会出现在你的网页设计生涯中,在您的网站变成真正的流行点。这是当企业成为您的网站上刊登广告感兴趣。可以建立一个横幅广告系统,控制所有你所以愿意以优惠的价格,以显示这些广告。Active Server Pages的,使得它很容易地创建一个横幅广告系统。那么容易,微软的ASP开发人员创建了一个组件

30、之际的“AdRotator”。在你开始阅读本文之前,确保你下载下面的支撑材料。这些文件包括ad.txtbanner.asp3 banner imagesclicks.aspexample.aspredirect.aspad.txt为了AdRotator组件来工作,你必须配置一个文本文件。这个文本文件包含了所有的横幅广告属性。然而,文本文件必须遵循一定的格式。前四行如下.REDIRECT redirect.aspWIDTH 400HEIGHT 50*重定向当点击旗帜“的AdRotator”组件去一个初步的页面。此页被称为重定向页面。重定向页面处理指导用户横幅目的地之前,任何额外的编程事件。在这个

31、例子中的旗帜,我称为“redirect.asp”初步文件。宽度此设置的横幅广告图片的宽度。该值必须以像素为单位。高度这设置的横幅广告形象的高度。该值必须以像素为单位。*星号告诉的“AdRotator”的组成部分,这是有关收购横幅广告信息。星号是必需的。一旦你定义了星号以上的一般性质,然后是列表显示的横幅。在ad.txt文件,有星号下面定义了三个横幅。banner1.jpgHTMLG20banner2.jpgY30banner3.jpgD30每个旗帜需要四行属性,按照下面的格式.图像的文件名网址描述旗帜重量影像档图像的文件名可以是一个完全合格的网络地址或相对指向图像的名称。如果图像是在不同的文件

32、夹,那么你还包括文件夹的名称。(banner.jpg)网址网络地址可以是您的网站或完全限定的网络地址,导致另一个网站的页面。描述说明将显示为工具提示。当你休息的旗帜,你的鼠标,弹出的描述。旗帜重量多少显示的一面旗帜,旗帜重量决定。“的AdRotator”组件添加了所有的旗帜权和决定的可能性或正在显示一个特定的横幅的机会。具有较高的权重的旗帜,具有较好的一个更好的概率。注意:您可以禁用代以破折号1横幅财产。banner3.jpg-待添加的隐藏文字内容3D30上面的条目示例将创建一个横幅广告,没有一个网址。banner.asp此文件使用“的AdRotator”组件和分析的ad.txt文件内容。下面

33、是代码。sub banner(strTarget)dim bannerad, htmlset bannerad = server.CreateObject(MSWC.adrotator)bannerad.TargetFrame = strTargethtml = bannerad.GetAdvertisement(ad.txt)Response.Write htmlend sub首先要注意的是用VBScript编写的ASP。第二件事要注意的是,代码内编写一个子过程称为横幅(strTarget)。对于那些你谁也不知道,子过程允许你组合到一起一堆代码可以一遍又一遍地重复使用。就像一个函数,它需要一

34、个参数,如一个字或变量。在上述参数的代码是strTarget。不像一个函数,子过程不返回任何值,它只是按行内执行的代码。内子,我声明两个变量.dim bannerad, html接下来,我将内部的“bannerad”变量“AdRotator的”组成部分。存储组件内部变量当您使用设定的关键字。因为我们是用ASP编程服务器端,我们使用Server.CreateObject,召唤组件。的“MSWC.adrotator”组件键或名称值。set bannerad = server.CreateObject(MSWC.adrotator)接下来,我使用“的AdRotator”称为“TargetFrame”

35、的属性。此属性相当于.目标的值可以是下列值之一._blankOpens the destination link in a new browser window._topOpens the destination link on top of the web page._parentOpens the destination link within a parent frame._newOpens the destination link in a new browser window.接下来,我使用“的AdRotator”的方法或函数称为“GetAdvertisement”,其结果存储在变量

36、的“HTML”。请注意,“GetAdvertisement”广告横幅文本文件作为一个参数的名称。html = bannerad.GetAdvertisement(ad.txt)最后,我想打印的“HTML”变量的内容。打印显示的横幅图片的代码。回复于HTMLredirect.asp这是被处理的文件之前,有人被重定向到的横幅网页地址。在这个文件中,我们可以抓住这样一个特定的旗帜多少次被点击等信息。要开始做事了,我定义了一个名为“strURL的变量。Dim strUrl接下来,我将这个新变量内查询字符串值。strUrl = Request.Querystring(url)一个QueryString是

37、什么比一堆连接到一个网址的名称/值对。当用户点击旗帜,“AdRotator的”组件重视querystring的重定向文件。因此,如果我们点击banner1.jpg定义,ad.txt的,我们将结束重定向网页地址看起来像这样.Redirect.asp?url=&image=banner1.jpg在本质分配“的Request.QueryString(”URL“)”strURL的“,是一样的,作为分配它。最后,我请检查被点击的旗帜。我与VBScriptINSTR()函数完成。if instr(strUrl, htmlgoodies) thenApplication.Lockapplication(ht

38、mlgoodies) = application(htmlgoodies) + 1Application.UnLockResponse.ClearResponse.Redirect strUrlend ifINSTR()函数返回在另一个单词(字符串)子字(子串)的位置。格式如下:InStr(main word, sub-word)如果分词存在于主词,那么该函数将等于大于零或真实的数字。如果不存在分词,那么该函数将等于零或虚假。我在上面的例子,请检查如果“htmlgoodies”的内存在。既然答案是真的,那么内,如果代码.然后.语句将执行。在if.然后.我使用的应用程序变量。一个应用程序变量是本

39、地的ASP。只要作为一个Web应用程序中存在的应用程序变量存储信息,web应用程序不再存在时,说有人关闭网站托管服务器。应用程序变量的好处是,你可以定义一个网页,并使用其他的网页,在你的web应用。倒台是在用户的计算机必须启用Cookie。不管怎么说,代码添加一个应用程序变量,每被点击时的一面旗帜。一个被添加后,代码重定向到横幅网页。所以如果Banner1产品被点击,那么你应重定向“”的。Response.Redirect strUrlExample.asp这是一个例子页面,使用横幅广告系统。当你刷新页面,你应该最有可能看到一个不同的旗帜。每当你要插入页面上的横幅广告,你可以使用SSI指令.一旦你有上面的文件,然后你可以调用子过程里,像这样的banner.asp文件.呼叫旗帜的(“_blank”)Call banner(_blank)请注意,我提供一个为“TargetFrame”作为一个参数值。因此,如果被点击的旗帜,然后在网页应开辟一个单独的浏览器窗口。Clicks.asp这是一个非常简单的页面,显示每横幅广告的点击数。要显示的横幅被点击的次数,你只是打印的应用程序创建的变量内“redirect.asp”的内容。非常漂亮。

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 办公文档 > 其他范文


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号