当前位置: 首页 > 网络学院 > 服务端脚本教程 > ASP > ASP AdRotator

ASP
ASP 介绍
ASP Install
ASP 语法
ASP 变量
ASP Procedures
ASP Forms
ASP Cookies
ASP Session
ASP Application
ASP #include
ASP Global.asa
ASP Send e-mail
ASP Response
ASP Request
ASP Application
ASP Session
ASP Server
ASP Error
ASP FileSystem
ASP TextStream

ASP AdRotator


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-01   浏览: 512 ::
收藏到网摘: n/a

Examples
举例

Simple AdRotator Example
简单AdRotator举例
This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page.
这个例子告诉我们如何使用AdRotator组件在用户每次访问页面或刷新页面时显示不同的广告图片。

AdRotator - The Images are Hyperlinks
AdRotator — 图片是超链接的形式
This example shows how to use the AdRotator component to display a different advertisement image, each time a user visits or refreshes the page. In addition, the images are hyperlinks.
这个例子告诉我们如何使用AdRotator组件在用户每次访问页面或刷新页面时显示不同的广告图片;另外,此时的图片是超链接的形式。


ASP AdRotator Component
ASP AdRotator 组件

The ASP AdRotator component creates an AdRotator object that displays a different image each time a user enters or refreshes a page. A text file includes information about the images.
我们可以通过ASP AdRotator组件是用来建立一个当用户每次访问或刷新页面时显示不同图片的AdRotator组件。一个文本文件中包含了这张图片的所有信息。

Syntax语法

<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>


Example
举例

Assume we have a file called "banners.asp". It looks like this:
假设我们建立了一个名为“banners.asp”的文件,代码如下:

<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("ads.txt"))
%>
</body>
</html>

The file "ads.txt" looks like this:
那么,这个“ads.txt”文件代码如下:

*
w3schools.gif
http://www.w3schools.com/
Visit W3Schools
80
microsoft.gif
http://www.microsoft.com/
Visit Microsoft
20

The lines below the asterisk in the file "ads.txt" specifies the images to be displayed, the hyperlink addresses, the alternate text (for the images), and the display rates in percent of the hits. We see that the W3Schools image will be displayed for 80 % of the hits and the Microsoft image will be displayed for 20 % of the hits in the text file above.
在“ads.txt”文件中,“*”号下面的代码定义了广告图片和链接显示的几率分别为80%和20%

Note: To get the links to work when a user clicks on them, we will have to modify the file "ads.txt" a bit:
提示:当用户点击这些广告获取链接时,我们将对“ads.txt”文件做一点修饰:

REDIRECT banners.asp
*
w3schools.gif
http://www.w3schools.com/
Visit W3Schools
80
microsoft.gif
http://www.microsoft.com/
Visit Microsoft
20

The redirection page (banners.asp) will now receive a querystring with a variable named URL containing the URL to redirect to.
这些重定向链接的页面(banners.asp)将获取一个名为URL的变量的字符串,它包含了URL的链接。

Note: To specify the height, width, and border of the image, you can insert the following lines under REDIRECT:
提示:你可以使用下面的代码定义图片的高度、宽度和边框属性:

REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3schools.gif
...
...

The last thing to do is to add some lines of code to the "banners.asp" file:
最后要做的就是往“banners.asp”文件中加入几行代码:

<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>

<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("textfile.txt"))
%>
</body>
</html>

That's all!!
结束!


Properties
属性

Property
属性
Description
具体描述
Example
举例
Border Specifies the size of the borders around the advertisement
定义广告的边框宽度
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Border="2"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
Clickable Specifies whether the advertisement is a hyperlink
决定广告是否已超链接的形式定义
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
TargetFrame Name of the frame to display the advertisement
定义所显示广告的框架名称
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.TargetFrame="target='_blank'"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>

Methods
方法

Method
方法
Description
具体描述
Example
举例
GetAdvertisement Returns HTML that displays the advertisement in the page
返回显示页面广告的HTML流。
<%
set adrot=Server.CreateObject("MSWC.AdRotator")
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>

评论 (0) All

登陆 | 还没注册?