动态网站制作指南



当前位置 > 网站建设学院 > 网络编程 > ASP实例 Rss
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket

动态广告管理程序制作例子


发表日期:2000-10-13


By Wayne Berry
This Issue
Many sites that are content specific depend on banner advertisement for revenue. Such is the case for 15
Seconds. A banner is displayed at the top of the page for every page viewed. Clients usually buy a set
number of banner imPRessions and these impressions are rotated amongst all the clients over a period of
time. In order to do this there must be a dynamic quality to the banners. In other Words, the banner to
display is not determined until that page is requested.
With an Active Server page this is an easy task. Active Server Pages are dynamic and there are many
components that handle the task of banner rotation. A simple one comes free with the Internet Information
Server, and more complicated rotation schedules can be done with Site Server and other third party
components. This article is not about how to implement these components within your Active Server pages,
since this is a fairly easy task.

This article will describe how to implement a banner rotation scenario where the pages served are static,
i.e. .htm, and do not have the flexibility to call components. The task is to dynamically serve banners
and statically serve pages. This is the opposite of the scenario for banner rotation components, which
statically serve banners and dynamically serve pages.

One Trick
There is only one trick here and once you know it the rest is pretty straightforward. Internet Explorer
and Netscape allow you to refer to an Active Server Page within an image tag. Example 1 demonstrates the
HTML to be inserted in the static page.
Example 1 : HTML Banner Reference



< IMG SRC="http://www.myserver.com/ServeBanner.asp">


Once you have referred to a dynamic Active Server page with the static page, you need to build an Active
Server page to return an image, in this case a banner. Example 2 shows the code to use for servebanner.asp
which is called in Example 1.

Example 2 : ServeBanner.asp Source



<%
Response.Redirect("http://www.myserver.com/banner.gif")
%>


These two pages combined will allow you to display to the user a banner as if you referred directly to the
banner image instead of an Active Server page. In order to do banner rotation all you have to do is expand
Example 2 so different images come up every time ServeBanner.asp is called.

Adding the Element of Rotation.
With this technique the dynamic aspect of the banner rotation is controlled within the Active Server page
that the IMG tag is referring to. In order to randomly rotate the banners you will need to change
ServerBanner.asp to choose a different banner each time that it is called. Example 3 shows how to do this.
Example 3 : Rotating Banners



<%

Dim Array(2)

' Initialize the VBScript Random
' Number Generator
Randomize

Array(1)="http://www.myserver.com/banner1.gif"
Array(2)="http://www.myserver.com/banner2.gif"

upperbound=UBound(Array)
lowerbound=1
lRandom = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

Response.Redirect(Array(lRandom))

%>


Notice that you will have to initialize the array for as many banners as are available and you will have
to assign a banner to each element of the array.

An Extra Benefit
An obvious benefit to this type of banner rotation is that fact that you don't have to serve Active Server
pages in order to have rotating banners. If the only dynamic aspect of your Active Server page is to
rotate banners you will want to change it to use this banner rotation technique, since it will reduce the
stress on your server.
It might not be so obvious that the static pages no longer need to reside on your machine to rotate
banners. For example, you could give the HTML in Example 1 to a site that you were advertising on, and
when they serve there pages with your HTML your server will rotate the banners for their site. This allows
you control of what banners are presented to their readers. The site that was serving the static pages
could even be a different Operating system, such as UNIX.

Clicking on the Banner
So far we have demonstrated how to rotate banners, but not how to activate those banners so that you can
click on the banner to go to another site. With one banner in the rotation this is a straightforward
process, you just point the anchor tag to the site which the banner represents. However when you have
multiple banners in the rotation it becomes more difficult. The problem is that a random banner is served
every time you request a page, however the anchor tag on that page does not change, since the page is
static.
To solve this problem the anchor tag needs to reference an Active Server page that can determine what
banner was being displayed so that it can redirect the browser to that page. Example 4 shows what the HTML
will look like to activate the banners in this banner rotation technique.

Example 4 : Activating the Banners



< A HREF=" http://www.myserver.com/BannerClick.asp">
< IMG SRC="http://www.myserver.com/ServeBanner.asp">
< /A>


BannerClick.asp now has the responsibility of redirecting to the correct location. However, currently
there is no way for BannerClick.asp to know which banner is being displayed to the user. In order to
determine this, ServeBanner.asp must tell the browser which banner it is going to display so that if the
user clicks through BannerClick.asp can ask the browser what banner was being shown. One way to do this is
to use cookies?. Example 5 shows how to modify ServeBanner.asp so that it sets a cookie every time a
banner is served.

Example 5 : Rotating Banners with Cookies



<%

Dim Array(2)

' Initialize the VBScript Random
' Number Generator
Randomize

Array(1)="http://www.myserver.com/banner1.gif"
Array(2)="http://www.myserver.com/banner2.gif"

upperbound=UBound(Array)
lowerbound=1
lRandom = Int((upperbound - lowerbound + 1) * Rnd + lowerbound)

Response.Cookies("BannerId")=lRandom
Response.Redirect(Array(lRandom))

%>


Once ServeBanner.asp is coded so that it issues a cookie for each request, and that cookie is the banner
identifier in the array, we can program ClickBanner.asp so that it reads the cookie and redirects to the
correct location. Example 6 shows how to implement ClickBanner.asp.

Example 6 : ClickBanner.asp



<%

Dim Array(2)

lBannerId  = Request.Cookies("BannerId")

Array(1)="http://www.client1.com"
Array(2)= "http://www.client2.com"

Response.Redirect(Array(lBannerId))

%>


Notice that the array is used differently in ServeBanner.asp then it is used in ClickBanner.asp. In
ServeBanner.asp the array referenced banner graphics, in ClickBanner.asp the array references the location
to go to when the banners is clicked. Since the index in the array is used in both locations the array
must be populated so that for every index the banner image matches the location.

Handling Netscape
The Netscape browser has a bug in it that needs to be avoided when rotating banners using this technique.
If you do not specify the size of an image in HTML Netscape queries the image itself to determine the
size. This is a feature that both Netscape and Internet Explorer have. However, Netscape queries the first
response to the image call for the size. Using this technique the first response is a set of headers that
are suppose to redirect the browser to the real graphic. When Netscape queries the headers for the image
size it fails since the response its not an image. In order to avoid this problem you will need to specify
the banner image size in the HTML. Example 7 shows Example 4 rewritten to specify the image size.
Example 7 : Setting the Image Size



< A HREF=" http://www.myserver.com/BannerClick.asp">
< IMG WIDTH=468 HEIGHT=60 SRC="http://www.myserver.com/ServeBanner.asp">
< /A>


Because of this bug there is no way to serve banners that are of varying sizes, since the size is
specified in a static page which does not change with the banner that is served.  
Beyond
The next step in creating your own banner rotation application is to put the banner arrays in a database
and to query the database every time a page is requested. This would allow you the flexibility to change
the banners using another set of Active Server pages which administers the database.
You could also implement a better rotation schema that would have a daily cap on the number of impressions
served and a maximum number of impressions to serve. You might also want to implement a default banner, so
that when the maximums are met there is something to rotate.

Another interesting addition would be the logging of the number of banners served and the number of click
throughs per banner. Then creating a set of Active Server pages to display the statistics in a variety of
forms.

However, before you go off and build yourself a database, and implement complicated banner rotation
algorithms you might want to consider buying a product that already does what you want. Banager
(http://www.banager.com) is an Active Server page application that is implemented using the techniques
discussed in this article. However, Banager has statistical pages, database logging and banner rotation
algorithms built in. In my opinion it is well worth the cost.

关注此文的读者还看过:
·2012-5-22 16:39:06 制作一个个人搜索引擎(源码)
·2012-5-22 16:37:04 一个ASP.NET+XML留言本例子
·2012-5-22 16:36:58 用ASP.NET建立简单的Web Form 
·2012-5-22 16:36:41 用asp解析图片地址,并将其保存。
·2012-5-22 16:36:22 用ASP开发一个在线考试程序(八)
·2012-5-22 16:35:15 asp实现k线图(在线)
·2012-5-22 16:34:43 jmail4.1用pop3收信的例子
·2012-5-22 16:33:21 用ASP开发一个在线考试程序(六)
·2012-5-22 16:27:21 用Asp隐藏文件路径实现防盗链
站长推荐 PS笔刷下载 在线翻译 系统进程 广告代码
  发表评论
姓 名: 验证码:
内 容:
教程搜索服务
ASP源码推荐
·FLASHZ网小偷带采集(直接生成HT
·茂名信息网在线管理系统 v1.5
·电子政务系统Beyondbit
·自由领域WEB+WAP同学录3.5版
·美女图片小偷程序4dzz专版 v1.0
·TVB影音在线(带数据带采集规则)
·时代网站信息管理系统SDCMS v1.
·6号联盟软件资讯 v1.0
·QQ表情站 Asp版
·文件批量上传客户端免费组件 v1
·千博购物系统生成静态HTML企业版
·蚊子小助手电话查询小偷
项目外包信息
·寻会php的程序员外包网站
·派桑网络-网络营销专家
·汽车配件网站制作 50000元
·整站SEO优化
·课件门户网程序
·求长期合作网站设计制作高手
·公司网站重新改版 8000元
·asp企业网站小改动
·网站flash片头
·文化传播公司网站设计稿
·UI界面设计
·产品外观改版设计 15000元
·照明灯具网站设计 10000元
·求长期合作网站设计制作高手
·做B2C网站 20000元
发布信息 浏览信息
邮件订阅服务
输入你的邮件地址,你将不会错过任何关于<ASP实例>的内容


网络编程文章分类
ASP教程
ASP实例
ASP技巧
ASP文摘
PHP教程
PHP技巧
PHP实例
PHP文摘
JSP教程
JSP技巧
JSP实例
JSP文摘
ASP.NET教程
ASP.NET技巧
ASP.NET实例
ASP.NET应用
xml教程
xsl教程
xml技巧
C#教程
C#应用
Delphi教程
Perl教程
Shell教程
Ajax教程
Visual Basic教程
Java教程
J2EE/J2ME教程
C/C++教程
移动解决方案
移动短信技术
移动行业动态
软件工程
WordPress
Android开发
站长工具:Google PR查询|Alexa排名查询|网站速度测试|CSS在线编辑器|OPEN参数生成器|弹出式窗口代码产生器|密码登录生成器|在线按钮生成器|Meta标签生成器|邮箱图标在线生成|多色彩特效字代码生成器|网页代码调试器|在线FTP登陆|Flash取色器|配色代码对照表|配色辞典|CSS生成器|CSS在线压缩|广告代码|框架网页代码生成器|js/vbs加密|md5加密|进制转换|UTF-8 转换工具|在线调色板|Html转换js|Html转换asp|Html转换php|Html转换perl
实用工具:汉字翻译拼音|拼音字典|在线翻译|天气预报|火星文|在线网速测试|符号对照表|个税计算|理财工具|黄金价格|购房银行按揭利率计算|汇率查询|经典小工具|汉字简繁转换|普通单位换算|公制单位换算|生辰老黄历|国内电话区号|国家代码与域名缩写|文字加密解密|元素周期表|健康查询|世界时间|全国各地车牌查询|全国车辆交通违章查询|万年历|二十四节气|汉字横竖排版|手机号码查询|计算器|ip搜索|酒店预订|机票预订
广告刊登 | 版权声明 | 联系我们 | 加入收藏 | RSS订阅
Copyright © 2000-2012 www.knowsky.com All rights reserved | 沪ICP备05001343号