Reply LinkBack Thread Tools Search this Thread
Old 10-06-2008, 13:27   #1 (permalink)
Yoyi
Senior Member
 
Yoyi's Avatar
 
Join Date: Jan 2007
Location: Miami, Florida, US
Posts: 345
Send a message via AIM to Yoyi Send a message via MSN to Yoyi
Java script to change image according to time of day

I know I have seen this before. Is a script that changes a specific image according to the time of day it is.


Anyone know where I might be able to find this?
__________________
www.spireconcepts.com

My cat is on Prozac
  Reply With Quote
Old 10-06-2008, 13:50   #2 (permalink)
pgo
Senior Member
 
Join Date: Jan 2005
Posts: 12,340
Use server-side scripting for that.
  Reply With Quote
Old 10-06-2008, 16:50   #3 (permalink)
jcblitz
Registered User
 
Join Date: Jun 2008
Posts: 11
I can think of a few ways, but can you give me more details? Do you want to do this only on load or if a person has been sitting idle from like say 3:48 and 4:00 rolls around, have it change. What type of frequency are we talking about? Night and evening?
  Reply With Quote
Old 10-06-2008, 17:27   #4 (permalink)
Yoyi
Senior Member
 
Yoyi's Avatar
 
Join Date: Jan 2007
Location: Miami, Florida, US
Posts: 345
Send a message via AIM to Yoyi Send a message via MSN to Yoyi
I want it to change say At
8:30am
10am
Noon
2:30pm
4:30pm


I want an image to load according to the time. Even if someone has their browser open at the time of the change. I want it to be as simple as possible, Java, or Actionscript is the only thing I can use for it.
__________________
www.spireconcepts.com

My cat is on Prozac
  Reply With Quote
Old 10-06-2008, 17:32   #5 (permalink)
robdesign
Registered User
 
Join Date: May 2008
Posts: 62
Send a message via AIM to robdesign Send a message via MSN to robdesign
Quote:
Originally Posted by Yoyi
I want an image to load according to the time. Even if someone has their browser open at the time of the change. I want it to be as simple as possible, Java, or Actionscript is the only thing I can use for it.

Why would that be necessary? It's not like somebody is going to leave the website pulled up on their computer on the same page for a whole day. I'd say use server-side scripting for your best bet.
  Reply With Quote
Old 10-06-2008, 17:41   #6 (permalink)
Yoyi
Senior Member
 
Yoyi's Avatar
 
Join Date: Jan 2007
Location: Miami, Florida, US
Posts: 345
Send a message via AIM to Yoyi Send a message via MSN to Yoyi
Its an intranet site, Some departments have it open at all times
__________________
www.spireconcepts.com

My cat is on Prozac
  Reply With Quote
Old 10-06-2008, 19:49   #7 (permalink)
karmedic
id
 
Join Date: May 2008
Location: Ottawa
Posts: 217
With a combo of datejs (www.datejs.com)and simple DOM manipulation you should be able to get what you're after relatively easy.

PSEUDO CODE
Code:
if (yourtime falls between timerange) document.getElementById('yourimageid).src = 'images/12-16.png'; else ...
  Reply With Quote
Old 11-06-2008, 05:14   #8 (permalink)
MikeMackay
Everything is fine.
 
MikeMackay's Avatar
 
Join Date: Feb 2005
Location: Witham & London
Posts: 828
Send a message via MSN to MikeMackay Send a message via Skype™ to MikeMackay
Have an array with every hour in it and with that hour associate an image...

$hours[0] => "pic1.jpg"
$hours[1] => "pic2.jpg"
...

Then, extract the hour from the current time and link it to that array. You could use a server-side script, or, a pure JavaScript solution would be adequate enough. If you used JS then you could use AJAX to update the time every X minutes and that in effect would update it live as the hour(s) pass.
__________________
  Reply With Quote
Old 11-06-2008, 06:45   #9 (permalink)
funkyprem
For all your goober needs
 
funkyprem's Avatar
 
Join Date: Dec 2004
Location: Coventry, UK
Posts: 1,531
__________________
Time is really the only capital that any human being has, and the one thing that he can’t afford to lose. - Thomas Edison

prem ghinde
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8