Home
Developer Blog
Ajax effects
CSS examples
Freelance jobs
Hot IT Jobs
Hot scripts
Code samples
Web hosting directory
Lotus Notes FAQ
See the new scripts recently added to Dynamic Drive.
Click here
.
Original, practical
CSS codes and examples
such as CSS menus for your site.
Search code samples
Keyword
All Categories
ASP
CSS
Dhtml
Html
Javascript
PHP
Code Samples
ASP
CSS
Dhtml
Html
Javascript
PHP
LOGIN HERE
Username
Password
Signup Now
Forgot Password
Verify Signup
Javascript >> Images
How can I load a different IMG depening on the time of the day?
Visitor Ratings (0) :
Description
Use
var now = new Date()
to get the current time and then document.write the IMG element
depening on the current hour:
Code
Select All
<SCRIPT> var firstImage = 'img1.gif'; varsecImage = 'img2.gif'; var now = new Date(); var hour = now.getHours(); if (hour >= 8 && hour <= 20) document.write('<IMG SRC="' + firstImage + '">'); else document.write('<IMG SRC="' +secImage + '">'); </SCRIPT>
Rate this Resource
0
1
2
3
4
5
6
7
8
9
10