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

ASP
ASP Drive
ASP File
ASP Folder
ASP Dictionary
ASP ADO
ASP AdRotator
ASP BrowserCap
ASP Content Linking
ASP Content Rotator
ASP Quick Ref
ASP 摘要
ASP 实例

ASP Content Rotator


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

Examples举例

The Content Rotator Component
This component displays a different HTML content string each time a user visits or refreshes the page.
Content Rotator组件
通过使用这个组件,当用户每次访问或刷新页面时,他都将显示不同的HTML内容字符串。


ASP Content Rotator Component
ASP Content Rotator组件

The ASP Content Rotator component creates a ContentRotator object that displays a different HTML content string each time a user enters or refreshes a page. A text file, called the Content Schedule File, includes the information about the content strings.
通过使用ASP Content Rotator组件建立一个ContentRotator对象,其用途是:当用户每次访问或刷新页面时,他都将显示不同的HTML内容字符串。一个我们称之为Content Schedule文件的文本文件,包含了内容字符串的所有信息。

The content strings can contain HTML tags so you can display any type of content that HTML can represent: text, images, colors, or hyperlinks.
内容字符串可以包含HTML标签,因此,你可以显示任何一种关于HTML内容的形式,如:文本、图片、颜色或者超链接。

Syntax语法

<%
Set cr=Server.CreateObject( "MSWC.ContentRotator" )
%>

The following example displays a different content each time a user views the Web page. Create a text file named "textads.txt" in your default Web Site folder, in a subfolder called text.
下面的例子展示的是,当每次用户访问页面时,页面将显示不同的内容。在你默认站点文件夹下的二级子目录下创建一个名为“textads.txt”的文本文件:

"textads.txt":

%% #1
This is a great day!!

%% #2
<h1>Smile</h1>

%% #3
<img src="smiley.gif">

%% #4
Here's a <a href="http://www.w3schools.com">link.</a>

Notice the #number at the beginning of each content string. This number is an optional parameter that indicates the relative weight of the HTML content string. In this example, the Content Rotator will display the first content string one-tenth of the time, the second string two-tenths of the time, the third string three-tenths of the time, and the fourth string four-tenths of the time.
注意:每个内容字符串开头的#number(数字)。这个数字是一个可选参数,它指明了HTML内容字符串的相对粗细程度。在这个例子中,ContentRotator将通过不同的几率显示不同的网页内容。显示第一个页面的几率是10%,第二个为20%,第三个为30%,第四个为40%。

Then, create an ASP file, and insert the following code:
此时,建立一个ASP文件,将下列代码插入其中:

<html>
<body>

<%
set cr=server.createobject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>

</body>
</html>

The ASP Content Rotator Component's methods are described below:
ASP Content Rotator 组件的具体使用方法描述如下:

Methods方法

Method Description Example
ChooseContent Gets and displays a content string <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.ChooseContent("text/textads.txt"))
%>

Output:
输出:

Smiley

GetAllContent Retrieves and displays all of the content strings in the text file <%
dim cr
Set cr=Server.CreateObject("MSWC.ContentRotator")
response.write(cr.GetAllContent("text/textads.txt"))
%>

Output:
输出:


This is a great day!!


Smile


Smiley


Here's a link.


评论 (0) All

登陆 | 还没注册?