ASPコンテンツローテーターコンポーネント(ASP 3.0)
ASPコンテンツローテーターコンポーネント
ASP Content Rotatorコンポーネントは、訪問者がページにアクセスまたは更新するたびに異なるコンテンツ文字列を表示するContentRotatorオブジェクトを作成します。
コンテンツスケジュールファイルと呼ばれるテキストファイルには、コンテンツ文字列に関する情報が含まれています。
コンテンツ文字列にはHTMLタグを含めることができるため、テキスト、画像、色、ハイパーリンクなど、HTMLで表現できるあらゆる種類のコンテンツを表示できます。
構文
<%
Set cr=Server.CreateObject("MSWC.ContentRotator")
%>
ASPコンテンツローテーターの例
次の例では、訪問者がWebページを表示するたびに異なるコンテンツを表示します。
まず、「textads.txt」という名前のテキストファイルを作成し、「text」という名前のサブフォルダーに配置します。
"textads.txt":
%% #3
<h2>This is a great day!!</h2>
%% #3
<img src="smiley.gif">
%% #4
<a href="https://www.w3schools.com">Visit W3Schools.com</a>
各コンテンツ文字列の先頭にある#numberに注意してください。この数値は、HTMLコンテンツ文字列の相対的な重みを示すオプションのパラメータです。上記のテキストファイルでは、コンテンツローテーターは1番目と2番目のコンテンツ文字列を10分の3の時間で表示し、3番目の文字列を10分の4の時間で表示します。
次に、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: |
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!! |