By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,687 Members | 2,065 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,687 IT Pros & Developers. It's quick & easy.

Wisdom requested on miscreant rotating banner! (image caching)

P: n/a
Hi,
I have been trying to put together a rotating banner. the code works
but I am having a problem with the caching of the banner images. no
matter what I try the page is constantly reloading the images, even
worse they are not loading completely. This version includes a (vain)
attempt at forcing the banner images to cache.
Apart form the caching problem the scripting seems to work

Any help welcomed:

Grunt

The code is
---------------------------------- in HEAD --------------------------
<script language="JavaScript" TYPE="text/javascript">
<!--
bannerImage1= new Image();
bannerImage2= new Image();
bannerImage3= new Image();
bannerImage4= new Image();
bannerImage1.src= "pageimages/banner1.gif";
bannerImage2.src= "pageimages/banner2.gif";
bannerImage3.src= "pageimages/banner3.gif";
bannerImage4.src= "pageimages/banner4.gif";
bannerImages = new
Array(bannerImage1,bannerImage2,bannerImage3,banne rImage4);
bannerLink = new
Array("firstbannerpage.html","secondbannerpage.htm l","thirdbannerpage.html","fourthbannerpage.html") ;
altLink = new Array("first link alt text","second link alt
text","third link alt text","fourth link alt text");
adIndex = 0;
adCount = bannerImages.length;

function bannerPage() {
var adPage = bannerLink[adIndex];
window.location = adPage;
}

function bannerAd() {
// control the rotating banners. The data objects are held in calling
page.
if (document.images) {
if (document.adImage.complete) {
adIndex++;
if (adIndex == adCount) {
adIndex=0;
}

document.adImage.src=bannerImages[adIndex].src;
document.adImage.alt=altLink[adIndex];

setTimeout("bannerAd()", 4*1000);
}
}
}
// -->
</SCRIPT>

----------------------- AND IN THE BODY ----------------------------
<BODY BGCOLOR="#FFFFFF" onLoad="bannerAd()">

<script language="JavaScript" type="text/javascript">
<!--
if (document.images)
{
document.write("<a href='javascript:bannerPage()'
<img src='pageimages/banner1.gif' name='adImage' width='453'

height='100' border='0' id='adImage'><\/a>")
}
else
{
document.write("<a href='firstbannerpage.html' ><span
class='content-head-purple12' id='headHiLite'>Get your hi-fi+
e-edition by clicking here<\/span><\/a>")
}
// -->
</script>
<noscript id="AltBanner">
<a href="firstbannerpage.html" ><img
src="pageimages/banner1.gif" name="adImage" width="453" height="100"
border="0" id="adImage"></a>
</noscript>

</body>

"In this world you can be either very very smart or very very pleasant. For
years I was smart.. I recommend pleasant". The wisdom of Elwood P. Dowd
Remove "removethis." to email
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Wed, 22 Sep 2004 18:49:30 GMT,
gr***@p1tman.removethispart.demon.co.uk (Grunt) wrote:
Hi,
I have been trying to put together a rotating banner. the code works
but I am having a problem with the caching of the banner images. no
matter what I try the page is constantly reloading the images, even
worse they are not loading completely. This version includes a (vain)
attempt at forcing the banner images to cache.
Apart form the caching problem the scripting seems to work

Any help welcomed:

Grunt


Can't help with the technical issue, but may I say that I am impressed
that you ask for wisdom rather than knowledge?

I hope this will extend to accepting that the answer might be "Don't
do this - it looks awful, is difficult for disabled access (which will
contravene legislation in both the USA and the EU) and irritates a lot
of people"?

Paul
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.