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="JavaS cript" TYPE="text/javascript">
<!--
bannerImage1= new Image();
bannerImage2= new Image();
bannerImage3= new Image();
bannerImage4= new Image();
bannerImage1.sr c= "pageimages/banner1.gif";
bannerImage2.sr c= "pageimages/banner2.gif";
bannerImage3.sr c= "pageimages/banner3.gif";
bannerImage4.sr c= "pageimages/banner4.gif";
bannerImages = new
Array(bannerIma ge1,bannerImage 2,bannerImage3, bannerImage4);
bannerLink = new
Array("firstban nerpage.html"," secondbannerpag e.html","thirdb annerpage.html" ,"fourthbannerp age.html");
altLink = new Array("first link alt text","second link alt
text","third link alt text","fourth link alt text");
adIndex = 0;
adCount = bannerImages.le ngth;
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.image s) {
if (document.adIma ge.complete) {
adIndex++;
if (adIndex == adCount) {
adIndex=0;
}
document.adImag e.src=bannerIma ges[adIndex].src;
document.adImag e.alt=altLink[adIndex];
setTimeout("ban nerAd()", 4*1000);
}
}
}
// -->
</SCRIPT>
----------------------- AND IN THE BODY ----------------------------
<BODY BGCOLOR="#FFFFF F" onLoad="bannerA d()">
<script language="JavaS cript" type="text/javascript">
<!--
if (document.image s)
{
document.write( "<a href='javascrip t:bannerPage()'[color=blue]
><img src='pageimages/banner1.gif' name='adImage' width='453'[/color]
height='100' border='0' id='adImage'><\/a>")
}
else
{
document.write( "<a href='firstbann erpage.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="firstbann erpage.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="JavaS cript" TYPE="text/javascript">
<!--
bannerImage1= new Image();
bannerImage2= new Image();
bannerImage3= new Image();
bannerImage4= new Image();
bannerImage1.sr c= "pageimages/banner1.gif";
bannerImage2.sr c= "pageimages/banner2.gif";
bannerImage3.sr c= "pageimages/banner3.gif";
bannerImage4.sr c= "pageimages/banner4.gif";
bannerImages = new
Array(bannerIma ge1,bannerImage 2,bannerImage3, bannerImage4);
bannerLink = new
Array("firstban nerpage.html"," secondbannerpag e.html","thirdb annerpage.html" ,"fourthbannerp age.html");
altLink = new Array("first link alt text","second link alt
text","third link alt text","fourth link alt text");
adIndex = 0;
adCount = bannerImages.le ngth;
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.image s) {
if (document.adIma ge.complete) {
adIndex++;
if (adIndex == adCount) {
adIndex=0;
}
document.adImag e.src=bannerIma ges[adIndex].src;
document.adImag e.alt=altLink[adIndex];
setTimeout("ban nerAd()", 4*1000);
}
}
}
// -->
</SCRIPT>
----------------------- AND IN THE BODY ----------------------------
<BODY BGCOLOR="#FFFFF F" onLoad="bannerA d()">
<script language="JavaS cript" type="text/javascript">
<!--
if (document.image s)
{
document.write( "<a href='javascrip t:bannerPage()'[color=blue]
><img src='pageimages/banner1.gif' name='adImage' width='453'[/color]
height='100' border='0' id='adImage'><\/a>")
}
else
{
document.write( "<a href='firstbann erpage.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="firstbann erpage.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
Comment