您现在的位置:计算机技术学习网 > 技术中心 > WEB编程 > ASP >

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

来源:网络 责任编辑:栏目编辑 发表时间:2013-07-01 16:29 点击:
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("/uploads/allimg/201208/20120809081953968.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)="/uploads/allimg/201208/20120809081956415.gif"
Array(2)="/uploads/allimg/201208/20120809081956431.gif"

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

    相关新闻>>

      发表评论
      请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。
      用户名: 验证码:点击我更换图片
      最新评论 更多>>

      推荐热点

      • WAP常见问题问答大全(四)
      • ASP开发必备:WEB打印代码大全
      • ASP调用系统ping命令
      • asp缓存技术
      • ASP教程:第三篇 ASP基础
      • 用ASP+XML打造留言本(4)
      • 关于ASP Recordset 分页出现负数解决方法及建议
      • 用asp怎样编写文档搜索页面(5)
      • ASP处理多关键词查询实例代码
      网站首页 - 友情链接 - 网站地图 - TAG标签 - RSS订阅 - 内容搜索
      Copyright © 2008-2015 计算机技术学习交流网. 版权所有

      豫ICP备11007008号-1