Ajax banner rotation ver. 1.2


    Custom JSP taglib lets you rotate ads on a website, even when the page is not reloaded. If your visitor will spend more time on a page, it makes sense to opt-in for displaying more than one ad at one page load.

Ad (or banner) here is a piece of HTML, rather than just image. Using HTML chunks you can present your ad as a formatted text, image etc.
 


<script language="JavaScript" src="cjajax.js"></script>

<%@ taglib uri="taglib.tld" prefix="a" %>

<a:AjaxBanner url="/servlet/NextAdd" timeout="120">

   your initial ad chunk is here

</a:AjaxBanner>

Here tag displays an initial ad chunk, waits 120 seconds and requests a next chunk. Your server-side can return a next ad chunk (just a text) or XML code with ad chunk and timeout for the next request.

More precisely: your server side can return either XML or plain text. In case of XML output taglib assumes that XML tag content contains a next ad block and XML tag timeout contains a new timeout (in seconds). For example:
 


<?xml version="1.0" ?>
<banner>
   <content><img src="ad.gif"></content>
   <reload>60</reload>
</banner>

In case of plain text it will be displayed as a new ad and default timeout will be used for the next request.

Negative value for the timeout means a permanent output (no next request will be raised).

You can assign some id to your ad block and request next ad block in JavaScript. Function name is getNextAdChunk_yourId() (yourId here is id for your block). For example:
 


<%@ taglib uri="taglib.tld" prefix="a" %>

<a:AjaxBanner id="block1" url="/servlet/NextAdd" timeout="120">

   your initial ad chunk is here

</a:AjaxBanner>

<script language="JavaScript">
   getNextAdChunk_block1();
</script>

Tags are:

AjaxBanner

Body tag lets you rotate ads without page reloading. Parameters are:

1) id Optional parameter. Describes a CSS/DHTML id for your ad block.
2) url Optional parameter. Describes an url for the 'next ad' request.
3) urlFunction Optional parameter. Describes a function that will return an url.
4) timeout Optional parameter. Describes a default timeout for the next request.
5) beforeAction Optional parameter. Describes a name for your own JavaScript function that will be called at the beginning of request. By default is empty.
6) afterAction Optional parameter. Describes a name for your own JavaScript function that will be called at the end of request. By default is empty.
 

for downloading:

 Library: ajaxbannertag.jar     Description: taglib.tld  JavaScript library: cjajax.js

 © Coldbeans      Comments?

See also Coldtags suite - the largest collection of custom JSP tags.

Also in Coldtags: