...

View Full Version : Day & Night Banner rotate



Chanse
09-21-2005, 08:27 AM
Hi,
Can some please Help.
I need a banner to change between 2 images for day and nighttime. Banner can change at 6 in the morning and 6 at night.
There is a lot of scripts on the net, but they can only be set for a couple of seconds or minutes.
Thanks
Chanse Turner

Badman3k
09-21-2005, 10:27 AM
Hey,

add this snippet of code into the head of your html page:

<script language="JavaScript">
<!--

function changeBanner(){

t = new Date();
hour = t.getHours();
if (hour >= 18 || hour < 6) {
document.getElementById("banner").src = "night.gif";
}
}


//-->
</script>

Then add onLoad="changeBanner();" to your body tag.

The img tag should have the id="banner" and the src of the day image.

Hope this helps

Chanse
09-26-2005, 01:25 AM
Hi Badman3k,
Thanks for the reply.
I have tried this, but it doen't seem to work.
Here is part of the source code.


<META NAME="ROBOTS" CONTENT="INDEX, FOLLOW">
<META NAME="REVISIT-AFTER" CONTENT="5 DAYS">
<META NAME="RATING" CONTENT="GENERAL">

<script language="JavaScript">
<!--
function changeBanner(){
t = new Date();
hour = t.getHours();
if (hour >= 18 || hour < 6) {
document.getElementById("banner").src = "themes/Aeolus/images/night.jpg";
}
}
//-->
</script>
</head>

<body onLoad="changeBanner();" background="themes/Aeolus/images/bg_main.gif" bgcolor="#000000" text="#FFFFCC" leftmargin="10" topmargin="10" marginwidth="10" marginheight="10">

<table class="bodyline" width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
<td align="center" valign="top">
<table width="99%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center" width="100%" height="110" background="themes/Aeolus/images/day.jpg" valign="top" id="banner">&nbsp;</td>
</tr>
</table>

Maybe it's something I've done wrong.
As you can see, the "day.jpg" is the background of a cell in a table.

Just have a look and see if I've got all the code in the right places.

Thanks.
Chanse Turner.

Badman3k
09-26-2005, 08:39 AM
Ahh I didn't realise it was the background to a cell.

Since this is the case, try replacing the line:

document.getElementById("banner").src = "themes/Aeolus/images/night.jpg";

with:

document.getElementById("banner").background = "themes/Aeolus/images/night.jpg";

and see if that works.

Chanse
09-26-2005, 11:33 AM
Hi Badman3k,
Thanks man you're a STAR... :) :) :) :thumbsup:
It's working now!!
I have added you to my ICQ list, I hope you've received the request from ICQ.
Thanks again.
Chanse Turner.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum