/    Sign up×
Community /Pin to ProfileBookmark

banner rotator w/ linking

Hello –

I downloaded the following banner swapper by Lee U. some time ago. I would like the banners to be able to link to a url. Is this possible? How?

Thanks for any help.

Nate

/* This script and many more are available free online at
The JavaScript Source :: [url]http://javascript.internet.com[/url]
Created by: Lee Underwood :: [url]http://javascript.internet.com/[/url] *
/

var bannerImg = new Array();
// Enter the names of the images below
bannerImg[0]=”image_jss.gif”;
bannerImg[1]=”image_js.gif”;
bannerImg[2]=”image_wr.gif”;

var newBanner = 0;
var totalBan = bannerImg.length;

function cycleBan() {
newBanner++;
if (newBanner == totalBan) {
newBanner = 0;
}
document.banner.src=bannerImg[newBanner];
// set the time below for length of image display
// i.e., “4*1000″ is 4 seconds
setTimeout(“cycleBan()”, 4*
1000);
}
window.onload=cycleBan;

<!– Paste this code into the HEAD section of your HTML document.
You may need to change the path of the file. –>

<script type=”text/javascript” src=”banner.js.js”></script>

<!– Paste this code into the BODY section of your HTML document –>

<img src=”image_jss.gif” name=”banner”>
<p><div align=”center”>
<font face=”arial, helvetica” size”-2″>Free JavaScripts provided<br>
by <a href=”http://javascriptsource.com”>The JavaScript Source</a></font>
</div><p>

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyJan 22.2009 — You'd have to change this:
[code=html]<img src="image_jss.gif" name="banner">[/code]
to this:
[code=html]<a href="link1.htm"><img name="banner" src="image_jss.gif" border="0"></a>[/code]
Change this:
[CODE]var bannerImg = new Array();
// Enter the names of the images below
bannerImg[0]="image_jss.gif";
bannerImg[1]="image_js.gif";
bannerImg[2]="image_wr.gif";[/CODE]

to this:
[CODE]// Enter the names of the images and urls below
var bannerImg = new Array(
[ "image_jss.gif", "link1.htm" ],
[ "image_js.gif", "link2.htm" ],
[ "image_wr.gif", "link3.htm" ]
); // no comma after last item above[/CODE]

And change this:
[CODE]document.banner.src=bannerImg[newBanner];[/CODE]
to this:
[CODE]var obj = document.images['banner'];
obj.src = bannerImg[newBanner][0];
obj.parentNode.href = bannerImg[newBanner][1];[/CODE]
×

Success!

Help @samovar spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.20,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...