ASP AdRotator Components
Whenever a user enters a Web site or refreshes a page, the ASP AdRotator component creates a AdRotator object to display a different picture.
Grammar:
The following are the referenced contents: <% Set Adrotator=server.createobject ("MSWC. AdRotator ") AdRotator. GetAdvertisement ("Textfile.txt") %> |
Instance
Suppose we have a file named "Banners.asp". It is similar to this:
The following are the referenced contents: <body%> <% Set Adrotator=server.createobject ("MSWC. AdRotator ") Response.Write (AdRotator. GetAdvertisement ("Ads.txt")) %> </body%> |
The file "Ads.txt" resembles this:
The following are the referenced contents: * Webjxcom.gif http://www.webjx.com/ Visit webjx.com 80 Microsoft.gif http://www.microsoft.com/ Visit Microsoft 20 |
The code below the asterisk in the "ads.txt" file defines how to display these images, the link address, the alternate text of the image, and the realistic probability of each of the hundreds of clicks. As we can see, the probability of a w3school picture is 80%, and the Microsoft picture has a 20% chance to display it.
Note: To make these links work correctly when the user clicks, we need to make a little bit of change to the file "Ads.txt":
The following are the referenced contents: REDIRECT banners.asp * Webjxcom.gif http://www.webjx.com/ Visit webjx.com 80 Microsoft.gif http://www.microsoft.com/ Visit Microsoft 20 |
The turn page receives a query string with a variable named URL that contains the URL to turn to.
Note: If you want to specify the height, width, and border of the image, we can insert the code below the redirect:
The following are the referenced contents: REDIRECT banners.asp WIDTH 468 HEIGHT 60 BORDER 0 * Webjxcom.gif ... ... |
The last thing to do is to add the code to the file "banners.asp":
The following are the referenced contents:
<% url=request.querystring ("url") If url<> "" then Response.Redirect (URL) %> <body> <% Set Adrotator=server.createobject ("MSWC. AdRotator ") Response.Write (AdRotator. GetAdvertisement ("Textfile.txt")) %> </body>
|