Thành phần ASP AdRotator
Thành phần ASP AdRotator
Thành phần ASP AdRotator tạo đố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 tin văn bản bao gồm thông tin về 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ề Công cụ quay vòng quảng cáo ASP
Giả sử chúng ta có tệp văn bản sau, có tên là "ads.txt":
REDIRECT banners.asp
*
w3s.gif
https://www.example.com.vn
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ế (đối với 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 (banners.asp) sẽ nhận được 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 "banners.asp" trông như thế này:
Ví 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>
Hiển thị ví dụ »
Đó 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 ASP AdRotator
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")) %> |