472,119 Members | 1,555 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,119 software developers and data experts.

Wisdom requested on miscreant rotating banner! (image caching)

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
1 1995
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.

Similar topics

2 posts views Thread by Derek | last post: by
4 posts views Thread by Ian Hubling | last post: by
4 posts views Thread by Roozbeh GHolizadeh | last post: by
5 posts views Thread by Gabriel Lozano-Morán | last post: by
3 posts views Thread by | last post: by
2 posts views Thread by mistral | last post: by
reply views Thread by mmcgee00 | last post: by
reply views Thread by jasone | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.