Thành phần ASP AdRotator


Thành phần ASP AdRotator

Thành phần ASP AdRotator tạo một đối tượng AdRotator hiển thị một hình ảnh khác nhau mỗi khi người dùng truy cập hoặc làm mới một trang. Một tệp văn bản bao gồm thông tin về các hình ảnh.

Lưu ý: AdRotator không hoạt động với Máy chủ Thông tin Internet 7 (IIS7).

Cú pháp

<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>

Ví dụ về ASP AdRotator

Giả sử rằng chúng tôi có tệp văn bản sau, có tên "ads.txt":

REDIRECT banners.asp
*
w3s.gif
https://www.w3schools.com
Free Tutorials from W3Schools
50
xmlspy.gif
https://www.altova.com
XML Editor from Altova
50

Các dòng bên dưới dấu hoa thị trong tệp văn bản ở trên chỉ định tên của hình ảnh (quảng cáo) sẽ được hiển thị, địa chỉ siêu liên kết, văn bản thay thế (cho hình ảnh) và tỷ lệ hiển thị (tính bằng phần trăm).

Dòng đầu tiên trong tệp văn bản ở trên chỉ định điều gì sẽ xảy ra khi khách truy cập nhấp vào một trong các hình ảnh. Trang chuyển hướng (banner.asp) sẽ nhận được một chuỗi truy vấn có URL để chuyển hướng đến.

Mẹo: Để chỉ định chiều cao, chiều rộng và đường viền của hình ảnh, bạn có thể chèn các dòng sau trong REDIRECT:

REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3s.gif
...

Tệp "banner.asp" trông giống như sau:

Thí dụ

<%
url=Request.QueryString("url")
If url<>"" then Response.Redirect(url)
%>

<!DOCTYPE html>
<html>
<body>
<%
set adrotator=Server.CreateObject("MSWC.AdRotator")
response.write(adrotator.GetAdvertisement("textfile.txt"))
%>
</body>
</html>

Đó là tất cả!!



Thuộc tính ASP AdRotator

Property Description Example
Border Specifies the size of the borders around the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Border="2"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
Clickable Specifies whether the advertisement is a hyperlink <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.Clickable=false
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>
TargetFrame Name of the frame to display the advertisement <%
set adrot=Server.CreateObject("MSWC.AdRotator")
adrot.TargetFrame="target='_blank'"
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>

Phương pháp trình duyệt quảng cáo ASP

Method Description Example
GetAdvertisement Returns HTML that displays the advertisement in the page <%
set adrot=Server.CreateObject("MSWC.AdRotator")
Response.Write(adrot.GetAdvertisement("ads.txt"))
%>