- Skill level:
Other People Are Reading
Things you need
- HTML or text editor
Open the page's HTML source code in an HTML or text editor.
Define the variable needed to rotate the banners in the HEAD section of the HTML code. This example uses three separate banners:
var MaxAds = 2
var ThisAd = new Array()
Assign values to each of the banner array members. This code also belongs in the HEAD section of your HTML code directly below the variable declarations:
ThisAd = '<img src="firstbanner.jpg" width="190" height="40" border="0">'
ThisAd = '<img src="secondbanner.jpg" width="190" height="40" border="0">'
ThisAd = '<img src="thirdbanner.jpg" width="190" height="40" border="0">'
Place the script that rotates the banners in the BODY section of your HTML code:
AdNumber = Math.round(Math.random() * MaxAds)
Save the file and close the editor.
Tips and warnings
- In the example, the graphic banner files are placed in the same directory as the HTML file for calling the page. These may be placed anywhere on the server by specifying the path along with the file name.
- The MaxAds variable is declared as 2 to give a maximum of 3 array members since array counting always begins with 0 instead of 1.
- 20 of the funniest online reviews ever
- 14 Biggest lies people tell in online dating sites
- Hilarious things Google thinks you're trying to search for