首 页 网络编程
网页制作 图形图象 操作系统 冲浪宝典
软件教学 认证考试

网络安全 网络办公 行业资讯 评测对比
您当前位置:站长天空 -> 网络编程-> ASP教程
制作一个简单的广告系统-ASP教程,ASP应用
作者:网友供稿 点击:4
推荐
西部数码-全国虚拟主机10强!20余项虚拟主机管理功能,全国领先!第6代双线路虚拟主机,南北访问畅通无阻!可在线rar解压,自动数据恢复设置虚拟目录等.免费赠送访问统计,企业邮局.Cn域名注册10元/年,自助建站480元起,免费试用7天,满意再付款!P4主机租用799元/月.月付免压金
站内搜索
文章页数:[1] 
by manohar kamath
august 9, 1999

creating a advertisement rotator page is easy - asp comes with an adrotator component thats easy to use.
the component, called adrotator, is installed when you install asp. the component has been a part of asp
installation since the first version of asp.

there are 3 parts to the ad rotator system:

ad rotator logic page
ad images date file
redirection page
ad rotator logic page
create a file say ads.inc, an include file that can be included on any asp page on your site. this file
will actually "create" the image links on the asp pages. the page makes use of the file in item 2, the ad
images data file to choose the image from the list of images.

the code is as shown below. i created a function getad() so that this function can be called within any
asp page where you want the banners to show up. the advantage of putting the logic in the function is
obvious - reuseability of code.

<script language=vbscript runat=server>
function getad()
dim load
create an instance of the adrotator component
set load = server.createobject("mswc.adrotator")

set the target frame, if any. this is the frame the where ad
url will open up. if the html page does not find the target name
the url will be opened in a new window
load.targetframe = "target=new"

get a random avertisement from the text file
this file is in the /ad folder
getad = load.getadvertisement("/ad/adrotator.txt")
end function
</script>

ad images data file
create the ad information file, say adrotator.txt. this file has two parts

general information for all the images - this information is applied to all images that are rotated. this
section contains 4 parts

redirect - the page that will handle the redirects. you can specify a absolute or a relative url for this
page
width - width of the images. if not specified, defaults to 60
height - height of images. if not specified, defaults to 440
border of the image. if not specified, defaults to 1
individual image information. this section is separated from the first by a single "*" on a separate line
as shown in the code below. this section has four parts

image source - either absolute, relative or a url like http://...
redirect url - the url to be sent when the user clicks on the image
alternate text - a brief description of the ad that appears in text browsers, or when the images are
turned off
ad weight - a number between 0 and 4,294,967,295 that determines the frequency of that ad display. a
weight of 0 means the ad will never be displayed. higher the number, more frequent the display is.
e.g. in the example below, the weights of two images are 2 and 3. so, the second image is 3 times more
likely to appear for every 2 appearance of first.

assuming the images are in the /images directory, a sample adrotator.txt file is shown below. the *
separates the general data from the image info. within the images info, leave a blank line between each
image data.

redirect adredir.asp
width 468
height 60
border 0
*
/images/fp2000.gif
http://www.microsoft.com/frontpage
microsoft frontpage 2000
2

/images/office2000.gif
http://www.microsoft.com/office
office 2000
3

redirection page
the redirection page, receives in its querystring, a variable named url that contains the url to redirect
to, and another variable image that contains the image url of the ad image. the image variable is more for
statistical purposes, to keep count of what image appeared when and how many times etc. so, if you were to
keep count of what images were clicked, you would log this into a database (there are better ways, but
just trying to illustrate why the variable is passed).

a simple redirect page, adredir.asp, is as follows. it essentially retrieves the url from the querystring
and does a response.redirect to it.

<%@language=vbscript %>
<%
set the response buffer on
response.buffer = true
dim lsurl
obtain the url from the querystring
lsurl = request.querystring("url")
clear the response and redirect to url
response.clear()
response.redirect(lsurl)
%>

using the system
include the file ads.inc on any asp page you want to show the banner ad. then, on the page, call the
function getad() at any point, however times you like to create as many ad banners. an example is as shown
below:

<!--#include virtual="/ad/ads.inc"-->
<html>
..
<!--the ad banner goes here-->
<p><%=getad()%></p>
...
</html>

文章整理:站长天空 网址:http://www.z6688.com/
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

文章页数:[1] 


放大字体显示 缩小字体显示 打印文章 推荐给朋友
热门文章
·在ASP.NET中使用Office Web Components (OWC)创建统计图-.NET教程,数据库应用
·windows系统下jsp+mysql+tomcat的配置-JSP教程,Application/Applet
·把aspx文件编译成DLL文件-.NET教程,Asp.Net开发
·Haneng.com的简单留言板制作源程序例子-ASP教程,ASP应用
·使用VB实现邮箱自动注册(一):表单自动提交-.NET教程,VB.Net语言
·VS.NET安装指南(To菜鸟)-.NET教程,Asp.Net开发
·web下水晶报表的使用!-.NET教程,Web Service开发
·C# 静态成员和方法的学习小结-.NET教程,数据库应用
·IIS的使用-ASP教程,ASP基础
·asp讲座之二:读取通过表单发送的数据
最新文章
·photoshop鼠绘实例:浪漫夏夜壁纸_photoshop教程
·买卖中小网站交易的一些细节问题_站长心得
·七招打造最安全的windows xp操作系统_windows xp
·做google adsense最佳和最重要的要诀_网赚技巧
·上下文关联广告清单(内文广告)推荐_网赚技巧
·广告联盟,痛定思痛_网赚技巧
·insenz首批广告费发放给站长_网赚技巧
·李彦宏:三分之一时间用在寻找人才_站长访谈
·中国汽车资源网杨锁民:网络寒冬时下海_站长访谈
·做it新闻资讯网站应先学新浪_站长心得
相关主题
  • 制作一个简单的setup_delphi教程
  • 制作一个简单的服务器端控制-ASP教程,ASP基础
  • 制作一个简单的服务器端控制
  • 西部数码虚拟主机

    友情链接
    CNNIC 西部数码
    万网 自助建站
    虚拟主机 asp空间
    域名注册 域名
    域名申请 主页空间
    论坛空间 网站空间
    国际域名 虚拟空间
    空间租用 DDOS防火墙
    成都主机托管 四川主机托管
    主机租用 服务器租用
    网站目录 自助建站
    虚拟主机 网址大全
    软件下载
    自助链接
    虚拟主机资讯 特价虚拟主机
    版权申明:本站文章均来自网络,如有侵权,请联系我们,我们收到后立即删除,谢谢!
    关于我们:站长天空:专业提供最新的站长资讯、在线教程、虚拟主机权威评测、虚拟主机性能对比、网站制作教程,开发教程,站长工具。包括网页制作教程、冲浪宝典、编程参考、操作系统、软件教学、行业动态等。
    特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有。
    发表评论 打印  刷新     关闭