通行证: 用户 密码 域名空间  下载中心 社区论坛 信息公告 MY小屋
联系我们
设为首页
加入收藏

 

QQ,ASP,PHP,JSP,XML,SQL,.Net,编程 程序 网页图象 建站经验 私服
首页 | 新闻资讯 | 编程开发 | 网页设计 | 图形图象 | 网络媒体 | 网站模板 | 数 据 库 | 投稿
论坛 | 操作系统 | 系统优化 | 网络安全 | 黑客技术 | 硬件学堂 | 硬件报价 | 服 务 器 | 地图
专题 | 应用软件 | 聊天通讯 | Q Q 专栏 | 建站经验 | 在线工具 | 站长Club | 注 册 表 | 旧版
社会 | 游戏娱乐 | 设计欣赏 | 疑难解答 | 社区论坛 | 韩国素材 | 素材图库 | 广告服务 | 服务
当前位置:首页>>编程开发>>asp专区>>正文 新版上线![旧版]
注:打开慢时请稍等

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

http://www.iyit.net  日期:2006-6-7 10:47:59  来源:不详  点击:
参加讨论】   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.

 

编辑:黑鹰 [发送给好友] [打印本页] [关闭窗口] [返回顶部]
上一篇:深入研究“用ASP上载文件”(一)
下一篇:广告播放和跟踪系统的制作
转载请注明来源:www.iyit.net
特别声明: 本站除部分特别声明禁止转载的专稿外的其他文章可以自由转载,但请务必注明出处和原始作者。文章版权归文章原始作者所有。对于被本站转载文章的个人和网站,我们表示深深的谢意。如果本站转载的文章有版权问题请联系编辑人员,我们尽快予以更正。

 相关文章
用php实现广告轮播 随机广告显示(PHP函数) 用PHP实现小型站点广告管理
一个广告轮播系统的例子(内含文件上传 动态显示图片的函数(显示广告条) 灵活实用的页面广告实例
动态显示图片的函数(显示广告条) 建立一个广告交换及跟踪系统 广告播放和跟踪系统的制作
一个基于ASP的标题广告管理系统(一) 一个基于ASP的标题广告管理系统(二) 一个基于ASP的标题广告管理系统(三)
DW MX实例:动态广告管理 打击广告防毒 部分QQ号码需重新激活 教你清除QQ空间右上方广告
用AJAX跟踪Google Adsense广告点击 动态显示图片的函数(显示广告条) 广告轮播
摆脱广告骚扰 还我清静网络世界 什么是广告软件Adware 什么是广告软件Adware
狙击疯狂的 Windows 信使广告 网站广告怎样做效果最好? 各类个人网站有效地赚广告费体会谈
最新更新 热点排行 推荐新闻
ASP初学者常犯的几个错误
rs.open sql,conn,1,1全接触
处理较长文章,添加 …… 效果
[ASP]利用 xmlhttp 分块上传文件
asp,php 和 jsp 比较 之我见
ncsc
重庆大学生引资百万建网站半年倒闭
PHP安装攻略:安装并配置PHP
PHP应用分页显示制作详细讲解
MySQL数据库基础教程
Php利用java解析xml
使用PHP实现动态网页
使用PHP和XSL stylesheets转换XML文档
在php中输出html代码
关于session的问题集锦解决方案
用ASP+XMLHTTP编写天气预报程序
ASP如何获取真实IP地址
VS .net 2003调试javascript中两个杂症
datagrid编辑、修改、删除、翻页例子
rs.open sql,conn,1,1全接触
QQ密码本地破解
msn8.0下载
珊蝴虫QQ探测隐身的招式用法
Visual Basic 概述
exeplorer.exe错误的问题的总结、解决
解决Windows中的explorer.exe出错
Authorware7.0基础与实例教程连载 第5
PPLive最新内部版本揭密
Windows常见文件修复技巧
一个好汉N个帮 Word实用插件集锦
ASP 五大高效提速技巧
ASP中使用SQL语句教程
测试一下喽!
Windows下的虚拟主机设置全功略
危险无处不在 Html标签带来的安全隐患
网络游戏是06年互联网最具发展潜力业务
巧用ACDSee 8.0截取QQ表情每一帧
解除瑞星 诺顿遗留下的杀毒兼容问题
第一款开源AJAX安全扫描工具Sprajax
WinRAR人性化功能揭密
在ASP.NET中防止注入攻击
用ASP.NET开发Web服务的五则技巧
Linux操作系统12则经典应用技巧
 友情链接
设置首 页 - 版权声明 - 广告服务 - 关于我们 - 联系我们 - 友情连接
Copyrights © 2004-2006 iYiT.Net All Rights Reserved.
网站合作、广告联系QQ:147007642、466949678
易特网络技术 点击这里给我发消息