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.w3schools.com">Visit W3Schools.com</a>

각 콘텐츠 문자열의 시작 부분에 있는 #number를 확인하십시오. 이 숫자는 HTML 콘텐츠 문자열의 상대적 가중치를 나타내는 선택적 매개변수입니다. 위의 텍스트 파일에서 Content Rotator는 시간의 1/10의 첫 번째 및 두 번째 콘텐츠 문자열을 표시하고 시간의 1/10인 세 번째 문자열을 표시합니다.

그런 다음 ASP 파일을 만들고 다음 코드를 삽입합니다.

예시

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



ASP Content Rotator 구성 요소의 메서드

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 W3Schools.com