ASP 内容加载器组件(ASP 3.0)


ASP 内容加载器组件

ASP Content Rotator 组件创建一个 ContentRotator 对象,每次访问者进入或刷新页面时,该对象都会显示不同的内容字符串。

称为内容计划文件的文本文件包含有关内容字符串的信息。

内容字符串可以包含 HTML 标签,以便您可以显示 HTML 可以表示的任何类型的内容:文本、图片、颜色或超链接。

语法

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

ASP 内容加载器示例

以下示例在访问者每次查看网页时显示不同的内容。

首先,创建一个名为 "textads.txt" 的文本文件,并将其放置在名为 "text" 的子文件夹中。

"textads.txt":

%% #3
<h2>This is a great day!!</h2>

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

%% #4
<a href="https://www.91xjr.com">Visit 91xjr.com</a>

请注意每个内容字符串开头的#number。该数字是一个可选参数,指示 HTML 内容字符串的相对权重。在上面的文本文件中,内容加载器将在十分之三的时间显示第一和第二内容字符串,并在十分之四的时间显示第三个字符串。

然后,创建一个 ASP 文件,并插入以下代码:

示例

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

显示示例 »


ASP 内容加载器组件的方法

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!!

Smiley

Visit 91xjr.com