Recommended: Introduction to the six major ASP objects Application Objects The Application object is an application-level object that shares information among all users and can persist data during the run of a web application. Application properties: The method is as follows: Application object does not
ASP AdRotator Component
Whenever a user enters a website or refreshes a page, the ASP AdRotator component creates an AdRotator object to display a different image.
grammar:
| The following is the quoted content: <% set adrotator=server.createobject(MSWC.AdRotator) adrotator.GetAdvertisement(textfile.txt) %> |
Example
Suppose we have a file named banners.asp. It looks like this:
| The following is the quoted content: <html%> <body%> <% set adrotator=Server.CreateObject(MSWC.AdRotator) response.write(adrotator.GetAdvertisement(ads.txt)) %> </body%> </html%> |
The file ads.txt looks like this:
| The following is the quoted content: * CuoXIncom.gif http://www.CuoXIn.com/ Visit CuoXIn.Com 80 microsoft.gif http://www.microsoft.com/ Visit Microsoft 20 |
The code below the asterisk in the ads.txt file defines how these images, link addresses, replacement text of images, and realistic chances of every hundred clicks. We can see that the probability of displaying W3School images is 80%, while the probability of displaying Microsoft images is 20%.
Note: In order for these links to work properly when the user clicks, we need to make a little modification to the file ads.txt:
| The following is the quoted content: REDIRECT banners.asp * CuoXIncom.gif http://www.CuoXIn.com/ Visit CuoXIn.Com 80 microsoft.gif http://www.microsoft.com/ Visit Microsoft 20 |
The turn page receives a query string for a variable named url, which contains the URL for turning.
Note: To specify the height, width and border of the image, we can insert these codes under REDIRECT:
| The following is the quoted content: REDIRECT banners.asp WIDTH 468 HEIGHT 60 BORDER 0 * CuoXIncom.gif ... ... |
The last thing to do is add these codes to the file banners.asp:
| The following is the quoted content: <% url=Request.QueryString(url) If url<> then Response.Redirect(url) %> <html> <body> <% set adrotator=Server.CreateObject(MSWC.AdRotator) response.write(adrotator.GetAdvertisement(textfile.txt)) %> </body> </html> |
Share: Use ASP code to get the client IP and current address 1. Get the client IP<%myip=Request.ServerVariables(Remote_Addr)%>2. Get the current address and the referenced content: <script>document