Using the Ad Rotator component

Source: Internet
Author: User
Tags contains iis first row
Internet Web sites often offer ad space. To keep the site real and interesting and display several advertisers ' ads in a limited space, you might want to loop through different ads. The Ad Rotator component simplifies the task of displaying each ad in turn, and it is easy to add new ads. In addition, you can easily add or update hyperlinks that allow users to click Ads and then visit advertisers ' web sites. In this course, you will create a script that invokes the Ad Rotator component to rotate four randomly selected ads.

Create an ad file

1. We have created an imaginary business Web page, our exotic journey, where we can insert the Ad rotator script. You can also create a simple text file that notifies the Ad Rotator component which ads to insert and the percentage of time each ad displays. We have created the file that contains the advertisement. To view the file, use a text editor to open the file Adrot.txt in the localhost Web server Tutorial directory (c:\winnt\help\iishelp\iis\htm\tutorial).

The first line of the file sets the script that will be invoked when the user clicks the ad; here is redirect.asp. You can modify the redirect.asp file to perform specific actions before you link users to an advertiser Web site, such as tracking the popularity of an ad. The following three lines establish the width, height, and edge width of the advertising image.

Width 180
Height 180
Border 1
Next, the file contains the ad data. For each ad, the data includes the image to use, the URL to go to when the user clicks the ad (in this case, go to redirect.asp), the text associated with the image, and the percentage of time the advertisement will display:

Big deals in the big Apple
Maintain ad information in separate files, and other groups in your organization can update Adrot.txt files without requiring you to update ASP pages. Different groups can maintain different ad files for each part of the site.

Creating scripts
Open the file exotic.asp in the Localhostweb Server Tutorial directory (c:\winnt\help\iishelp\iis\htm\tutorial) using a text editor.

At the top of the exotic.asp, paste the following script line before any other HTML tag or ASP command:
<%@ Language=vbscript%>
This script is an ASP command statement that notifies WEB server scripts to be written in VBScript. This command statement must be in the first row of the ASP file.

Search term "guide course: Ad Rotator"; You will add a script here.
Create an instance of the Ad Rotator component and assign it to the variable ad by copying the following script command and pasting it into a text editor (after the text line in the previous step):
<% Set Ad = Server.CreateObject ("MSWC. Adrotator ")%>
Assigning a component instance to a variable allows you to refer to the component in a future script.

This script command already exists if other users have completed this section of the guide. Paste the copied script to replace the existing script, or copy the unedited exotic.asp from the Template (c:\winnt\help\iishelp\iis\htm\tutorial\template) directory to the Tutorial directory.

To display new ads, you can use the GetAdvertisement method of the Ad Rotator component. Add the following script commands to the script:
<%= ad.getadvertisement ("Adrot2.txt")%>
The GetAdvertisement method has a parameter (the file name that contains the advertisement information, here is Adrot2.txt, this file is configured and differs from Adrot.txt). Based on this parameter, this method returns the HTML tag that has been fully formatted for the advertisement. The variable name ad assigned to the Ad Rotator component instance is located in front of the method getadvertisement and Adrot2.txt file path. The equal sign sends the value returned by the method (the actual advertisement) to the user's browser.

Saves changes to exotic.asp in text format and exits the text editor. Make sure that the text editor does not replace the. asp file name extension.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.