Wednesday, July 1, 2009

Text Link Ad Rotation using jQuery

People who have been monetizing their sites need no introduction to Text Link Ads. In simple words, Text Link Ads are Hyperlinks sponsored by Advertisers. When a user clicks on these hyperlinks, they are sent to the sponsor’s website.

In this post, we will see how to rotate Text Link Ads on the same position. I will use the Cycle Plug-in for this purpose, since it accomplishes this task in just one line of code. Download the Cycle Plugin.

<html xmlns="http://www.w3.org/1999/xhtml">
<
head>
<
title>Text Link Ad Rotationtitle>
<
script type="text/javascript"
src="http://code.jquery.com/jquery-latest.js">
script>
<
script type="text/javascript"
src="Scripts/jquery.cycle.all.min.js">
script>

<
script type="text/javascript">
$(document).ready(function() {
$('#Links').cycle('fade');
});
script>

<
style type="text/css">
body
{
font-size:13px;
font-family:"Lucida Grande", "Lucida Sans Unicode";
color:#444444;
}
style>

head>
<
body>
<
div id="Links">
<
a href="http://www.niksgaur.blogspot.com">>My Software and web development Experiencea>
<
a href="http://www.engcolgs.blogspot.com">My College Lifra>
<
a href="http://authornitin.blogspot.com">Canvassa>
div>
body>
html>

You can use the Effects Browser page to preview all the effects that are available with the Cycle Plug-in.

Note: To rotate ASP.NET Hyperlinks, replace the HTML links with the following:

<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="http://jquery.com">jQueryasp:HyperLink>

There’s no need to change any other code since this asp.net control gets rendered as html A tag

You can see a live demo of the example given in this post over here. The Link Rotates after every few seconds.

No comments: