Komponent ASP AdRotator
Komponent ASP AdRotator
Komponent ASP AdRotator tworzy obiekt AdRotator, który wyświetla inny obraz za każdym razem, gdy użytkownik wchodzi lub odświeża stronę. Plik tekstowy zawiera informacje o obrazach.
Uwaga: AdRotator nie działa z Internet Information Server 7 (IIS7).
Składnia
<%
set adrotator=server.createobject("MSWC.AdRotator")
adrotator.GetAdvertisement("textfile.txt")
%>
Przykład ASP AdRotator
Załóżmy, że mamy następujący plik tekstowy o nazwie „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
Wiersze pod gwiazdką w powyższym pliku tekstowym określają nazwę obrazów (reklam), które mają być wyświetlane, adresy hiperłączy, tekst alternatywny (dla obrazów) oraz częstotliwość wyświetlania (w procentach).
Pierwsza linia w powyższym pliku tekstowym określa, co się stanie, gdy użytkownik kliknie jeden z obrazów. Strona przekierowania (banners.asp) otrzyma ciąg zapytania z adresem URL do przekierowania.
Wskazówka: Aby określić wysokość, szerokość i obramowanie obrazu, możesz wstawić następujące linie w obszarze PRZEKIERUJ:
REDIRECT banners.asp
WIDTH 468
HEIGHT 60
BORDER 0
*
w3s.gif
...
Plik „banners.asp” wygląda tak:
Przykład
<%
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>
To wszystko!!
Właściwości 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")) %> |
Metody 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")) %> |