Wisdom requested on miscreant rotating banner! (image caching)

G

Grunt

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,bannerImage4);
bannerLink = new
Array("firstbannerpage.html","secondbannerpage.html","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
 
P

Paul Cooper

On Wed, 22 Sep 2004 18:49:30 GMT,
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,815
Latest member
treekmostly22

Latest Threads

Top