Brettb.Com
  HOME | ABOUT ME | BIOTECHNOLOGY | ARTICLES | GALLERY | CONTACT
Search: Go
TECHNICAL ARTICLES
 ASP
 ASP.NET
 JavaScript
 Transact SQL
 Other Articles
 Software Reviews

PHOTO GALLERIES
 Canon EOS 300D Samples
 Akihabara Maids!
 More Galleries...

TRAVEL LOG
 2009: China
 2008: Tokyo
 2007: Tokyo
 2006: Hong Kong
 2005: New York City

MORE STUFF
 Search Engine Optimisation
 Build an ASP Search Engine
 My Tropical Fishtank
 Autoglass
 SQL Month Name
 SQL Get Date Today
 SQL Year Month
 Other New Stuff...

POPULAR STUFF
 Regular Expressions
 Index Server & ASP
 JavaScript Ad Rotator

Home > JavaScript Articles

Java Banner Ad Rotator Applet

This simple Java Applet can be used to display a selection of images, each of which is linked to a different URL. Each of the images is shown after a specified amount of time.

Warning! Java is no longer supported by many web browsers, so consider using this JavaScript version of the banner ad rotator instead.

Applet Parameters

SleepTime: the number of seconds to wait before displaying next image.
DebugMode: include this parameter to turn on Applet debugging to the Java console.
ImageFolder: folder that contains the images.
CursorStyle: include this parameter to display a hand cursor when mouse is moved over Applet (instead of the default mouse pointer).
TargetFrame: the name of the frame in which to open the URL the Applet links to (default is same window).
Image1...10: name of the image file name (max. 10 images can be displayed).
Hyperlink1...10: URL that each image should link to.

Example Usage

The Banner Ad shown above was incorporated into the page using the following HTML:

<applet
code="BannerAdRotator.class"
name="BannerAdRotator"
width="468"
height="60" VIEWASTEXT>
<param name="SleepTime" value="6">
<param name="Image1" value="ASPDocumentationToolBannerAd3.gif">
<param name="Image2" value="WinnershTriangleWebSolutions_BannerAd.gif">
<param name="Image3" value="AmazonAd2_anim.gif">
<param name="Hyperlink1" value="hhttp://www.winnershtriangle.com/w/Products.ASPDocumentationTool.asp">
<param name="Hyperlink2" value="http://www.winnershtriangle.com/w/">
<param name="Hyperlink3" value="http://www.amazon.com/exec/obidos/redirect?tag=brettbcom&path=subst/home/home.html">
<param name="CursorStyle" value="hand">
<param name="TargetFrame" value="_blank">
<param name="ImageFolder" value="images/">
</applet>

Using the Applet on your website

To use the Applet on your website, save the following .class file somewhere in your website:

Once you have done this, modify the Applet's parameters as shown above. Don't forget to change the Applet's width and height to the same dimensions as your images.

Debugging

If the Applet does not appear to be working, then consider using the debug mode. This is activated by using the DebugMode parameter, e.g.

<param name="DebugMode" value="1">

The Applet will then output debugging information to the Java Console. On Netscape 4, the console is made visible using the menu command Communicator > Tools > Java Console.

Limitations

The Applet has to download each of the images over the Internet, so the fewer images you use the better performance the user will see. There is a hard coded limit of 10 images per Applet.

Although the Applet can display GIF images in animated GIF format, not all animations work particularly well.

Source Code

The source code for the Applet is available using the link below:

Legal issues

The Java Applet has been released as 'freeware'. No technical support is available for this product.

Other resources

  Site Map | Privacy Policy

All content is 1995 - 2012