PDA

View Full Version : Banner depending on the day


jonirvine
01-17-2001, 09:31 PM
Hi, I've seen a few like here on this, but I wouldn't know how to adapt them.

Need a javascript that will display a different banner for each day of the week. Ie banner 1 on Monday, 2 tuesady, etc

Possible? And if so would love the code.

Cheers

Ian
01-18-2001, 10:54 AM
Anything is possible :) well sometimes...

<script type="text/javascript" language="JavaScript">
var now = new Date ();
var day = now.getDay();
//by A1javascripts, please do not use in any other script library
//without linking to www.a1javascripts.com, (http://www.a1javascripts.com,) otherwise do what you like
//REMEMBER- the week begins on SUNDAY
if(day == 0) document.write("<a href='YOUR-LINK-HERE'><img src='/images/sundayimage.gif' alt='sunday' width='468' height='60' border='0'>");
if(day == 1) document.write("<a href='YOUR-LINK-HERE'><img src='/images/mondayimage.gif' alt='monday' width='468' height='60' border='0'>");
if(day == 2) document.write("<a href='YOUR-LINK-HERE'><img src='/images/tuesdayimage.gif' alt='tuesday' width='468' height='60' border='0'>");
if(day == 3) document.write("<a href='YOUR-LINK-HERE'><img src='/images/wednesdayimage.gif' alt='wednesday' width='468' height='60' border='0'>");
if(day == 4) document.write("<a href='YOUR-LINK-HERE'><img src='/images/thursdayimage.gif' alt='thursday' width='468' height='60' border='0'>");
if(day == 5) document.write("<a href='YOUR-LINK-HERE'><img src='/images/fridayimage.gif' alt='friday' width='468' height='60' border='0'>");
if(day == 6) document.write("<a href='YOUR-LINK-HERE'><img src='/images/saturdayimage.gif' alt='saturday' width='468' height='60' border='0'>");
</script>

um, is that any use to you? normal drama, change the alt, image and link to suit your needs. Good luck.

------------------
Ian

Web Development - BIG Resources Inc
Head Guide - 123Webmaster.com (http://www.123webmaster.com/)
ian@123webmaster.com
BIG Resources.com (http://www.bigresources.com)
ICQ: 25828668

kdjoergensen
01-18-2001, 11:06 AM
Here is an example:
<img name="myBanner" width=200 height=60>

<script language="javascript">
<!--
// Put this script AFTER the image.
var d = new Date();
var day = d.getDay(); //value 0-6 0=sunday.
var imgAry = new Array();
imgAry[0] = "sunBanner.gif"
imgAry[1] = "monBanner.gif"
imgAry[2] = "tueBanner.gif"
..
..
imgAry[6] = "satBanner.gif"
banner = new Image();
banner.src = imgAry[day];
document.myBanner.src = banner.src;
//-->
</SCRIPT>



[This message has been edited by kdjoergensen (edited 01-18-2001).]