SitePoint Sponsor |
|
User Tag List
Results 1 to 9 of 9
Thread: time-based image swap?
-
Nov 9, 2003, 21:07 #1
time-based image swap?
This is sort of a strange question, but here is what I am looking for:
I am designing a site for a radio show, I think it would be cool if I could get an image that says "on air" to display only when the host is on air (10-11, saturdays). Ideally, I would have a normal image with "on air" muted out all the time, except for when the show is on. Anyone have any idea how I might achieve this? Thanks in advance,
nat
-
Nov 9, 2003, 21:48 #2
- Join Date
- Sep 2002
- Location
- Bournemouth, South UK
- Posts
- 1,551
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Code:date=new Date() day=date.getDay() hours=date.getHours() minutes=date.getMinutes() seconds=date.getSeconds() if((day==n)&&(hours==22)) { change image script }
if you want it to happen after page has loaded, you'll need to create a setTimeout("checktimefunction()",n) to keep checking the time.LiveScript: Putting the "Live" Back into JavaScript
if live output_as_javascript else output_as_html end if
-
Nov 10, 2003, 14:03 #3
Thanks! I will give it a shot. I am not very good with JS, so I may need some more help. Thanks a lot,
nathan
Originally Posted by Markdidj
-
Nov 10, 2003, 22:24 #4
Mark:
Thanks for the tip, I was hoping you could point me in the right direction. I have started by just trying to make the script fire an alert to see if all that is straight. Let me know what I am doing wrong. The alert comes up as "undefined".
Here is the snippet:Code:<script language="javascript"> function popupMsg(msg) { //v1.0 alert(msg); date=new Date() day=date.getDay() hours=date.getHours() minutes=date.getMinutes() seconds=date.getSeconds() } </script> </head> <body onLoad="popupMsg()">
Originally Posted by Markdidj
-
Nov 11, 2003, 18:31 #5
- Join Date
- Sep 2002
- Location
- Bournemouth, South UK
- Posts
- 1,551
- Mentioned
- 1 Post(s)
- Tagged
- 0 Thread(s)
Code:<script language="javascript"> function popupMsg() { date=new Date(); day=date.getDay(); hours=date.getHours(); minutes=date.getMinutes(); seconds=date.getSeconds(); alert("Date="+date+"\n Day="+day+"\n Hours="+hours+"\n Minutes="+minutes+"\n Seconds="+seconds); } </script> </head> <body onLoad="popupMsg()">
LiveScript: Putting the "Live" Back into JavaScript
if live output_as_javascript else output_as_html end if
-
Nov 12, 2003, 12:10 #6
- Join Date
- May 2003
- Posts
- 1,843
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Code:<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>untitled</title> </head> <body bgcolor="#cc1028"> <img style="float:left;" name="aircheck" width="137" height="28" border="0" src="pixel.gif"> <script type="text/javascript" language="javascript"> var today = new Date(); var is_Saturday = (today.getDay() == 6); var is_ten_to_eleven = (today.getHours() == 22); if (is_Saturday && is_ten_to_eleven) document.images.aircheck.src = 'http://www.ksfo560.com/images/both_onair.gif'; </script> <strong style="color:#fff;">Your host: </strong> <img style="float:left;border:1px #fff dashed;" src="http://www.n-link.com/~autograph/box13.jpg"> </body> </html>
::: certified wild guess :::
-
Nov 12, 2003, 14:05 #7
- Join Date
- Nov 2002
- Location
- Malta
- Posts
- 1,111
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Just thought I'd point out that since javascript (in which I am no specialist) is client side scripting this will only be correct as long as the site visitor is in the same timezone as the radio station.
RikEnglish tea - Italian coffee - Maltese wine - Belgian beer - French Cognac
-
Nov 13, 2003, 14:41 #8
Hey, thanks! You guys have helped a ton.
Originally Posted by adios
-
Nov 13, 2003, 14:46 #9
- Join Date
- May 2003
- Posts
- 1,843
- Mentioned
- 0 Post(s)
- Tagged
- 0 Thread(s)
Zoef is right, though...
I'll get back to you on this (unless somebody who's good with dates does first).
::: certified wild guess :::
Bookmarks