...

View Full Version : Rotating a banner with time clock



Danno61
02-06-2007, 01:59 PM
I hope I am sincerely placing this in the right area.

I have a main banner (flash) on my site/message board and I would like to have 2 banners that rotate according to the time of day.

I would like to have the banner change at 7 P.M and 7 A.M. ( I have a night banner and a day banner.

I know this has to do with the If / else Code. I have no idea how to do this code.I have researched and cannot figure it out. If anyone can help it would be very appreciated!

The following is what I have right now for my code for a single banner.


<div class="borderwrap">
<div id="logostrip"><a href='{ipb.script_url}'>
<!--ipb.logo.start-->
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="900" height="240" align="absbottom">
<param name="quality" value="high">
<param name="SRC" value="/mybanners/mtt.swf">
<param name="SCALE" value="noborder">
<embed src="/mybanners/mtt.swf" width="900" height="240" align="absbottom" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" scale="noborder"></embed></object>
<!--ipb.logo.end-->
</a>
</div>

Thank you

Danno

neomaximus2k
02-07-2007, 09:48 AM
For this you would use a javascript time function, check if the time was less than 07 or greater than 19 and use innerHTML to change a DIV to show the correct banner



Stamp = new Date();
Hours = Stemp.getHours();

if (Hours <= 7){
//show night time banner
document.getElementById("logostrip").innerHTML = "<a href='{ipb.script_url}'><!--ipb.logo.start--><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"900\" height=\"240\" align=\"absbottom\"><param name=\"quality\" value=\"high\"><param name=\"SRC\" value=\"/mybanners/mtt.swf\"><param name=\"SCALE\" value=\"noborder\"><embed src=\"/mybanners/mtt.swf\" width=\"900\" height=\"240\" align=\"absbottom\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" scale=\"noborder\"></embed></object><!--ipb.logo.end--></a>";
} else if (hours >= 19){
//show nighttime banner
document.getElementById("logostrip").innerHTML = "<a href='{ipb.script_url}'><!--ipb.logo.start--><object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0\" width=\"900\" height=\"240\" align=\"absbottom\"><param name=\"quality\" value=\"high\"><param name=\"SRC\" value=\"/mybanners/mtt.swf\"><param name=\"SCALE\" value=\"noborder\"><embed src=\"/mybanners/mtt.swf\" width=\"900\" height=\"240\" align=\"absbottom\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" scale=\"noborder\"></embed></object><!--ipb.logo.end--></a>";
} else {
//show daytime
document.getElementById("logostrip").innerHTML = "<a href='{ipb.script_url}'><!--ipb.logo.start-->THIS IS THE SECOND ONE<!--ipb.logo.end--></a>";
}


of coure you would put that into a function to load on page load hope that helps



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum