📄 asp_contentrotator.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>ASP Content Rotator</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>ASP Content Rotator (ASP 3.0)</h1>
<a href="asp_contentlinking.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_quickref.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<hr />
<h2>Examples</h2>
<p><a target="_blank" href="showasp.asp@filename=demo_contentrotator">The Content Rotator Component</a><br />
This component displays a different HTML content string each time a user visits or refreshes the page.</p>
<hr />
<h2>ASP Content Rotator Component</h2>
<p>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.</p>
<p>The content strings can contain HTML tags so you can display any type
of content that HTML can represent: text, images, colors, or hyperlinks.</p>
<h3>Syntax</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<td><%<br />
Set cr=Server.CreateObject( "MSWC.ContentRotator" )<br />
%></td>
</tr>
</table>
<p>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.</p>
<p>"textads.txt":</p>
<table class="ex" cellspacing="0" cellpadding="3" width="100%" border="1">
<tr valign="top">
<td>%% #1<br />
This is a great day!!<br />
<br />
%% #2 <br />
<h1>Smile</h1><br />
<br />
%% #3<br />
<img src="smiley.gif"><br />
<br />
%% #4<br />
Here's a <a href="http://www.w3schools.com">link.</a></td>
</tr>
</table>
<p>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. </p>
<p>Then, create an ASP file, and insert the following code: </p>
<table class="ex" cellspacing="0" cellpadding="3" width="100%" border="1">
<tr valign="top">
<td><html><br />
<body><br />
<br />
<%<br />
set cr=server.createobject("MSWC.ContentRotator")<br />
response.write(cr.ChooseContent("text/textads.txt"))<br />
%><br />
<br />
</body><br />
</html></td>
</tr>
</table>
<p>The ASP Content Rotator Component's methods are described below: </p>
<h3>Methods</h3>
<table class="ex" cellspacing="0" border="1" width="100%" cellpadding="3">
<tr valign="top">
<th width="15%" align="left">Method</th>
<th width="35%" align="left">Description</th>
<th width="50%" align="left">Example</th>
</tr>
<tr valign="top">
<td>ChooseContent</td>
<td>Gets and displays a content string</td>
<td><%<br />
dim cr<br />
Set cr=Server.CreateObject("MSWC.ContentRotator") <br />
response.write(cr.ChooseContent("text/textads.txt"))<br />
%><p>Output:<br />
<br />
<img border="0" src="smiley.gif" alt="Smiley"></td>
</tr>
<tr valign="top">
<td>GetAllContent</td>
<td> Retrieves and displays all of the content strings in the text file</td>
<td> <%<br />
dim cr<br />
Set cr=Server.CreateObject("MSWC.ContentRotator") <br />
response.write(cr.GetAllContent("text/textads.txt"))<br />
%><p>Output:</p>
<hr />
<p>This is a great day!! </p>
<hr />
<h1>Smile</h1>
<hr />
<p><img src="smiley.gif" alt="Smiley"></p>
<hr />
<p>Here's a <a href="../default.htm">link.</a></p>
<hr /></td>
</tr>
</table>
<br />
<hr />
<a href="asp_contentlinking.asp"><img alt="previous" border="0" src="../images/btn_previous.gif" width="100" height="20" /></a>
<a href="asp_quickref.asp"><img alt="next" border="0" src="../images/btn_next.gif" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -