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()'
}
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
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()'
height='100' border='0' id='adImage'><\/a>")<img src='pageimages/banner1.gif' name='adImage' width='453'
}
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