Website Design United States, Website Design California, Website Designing United States, Website Designing California

Greeting By The Hour - JavaScript

This is a very simple script that will allow you to add a greeting to your webpage depending on the hour of the day.

The idea is simple but it can be used along with other scripts to do any number of things:

Change HTML elements (ex: background color) depending on the time
Rotate banners
Display different ads

Well you get the idea.


To use this script in your HTML document, place the source code above in the HEAD tag and then make the call in the BODY tag using:

greet_time()Good Day!

If you would prefer nothing to be shown when javascript is disabled then remove the Good Day! from in between the NOSCRIPT tags.

<script type="text/javascript">
// Document Greeting by the Hour - JavaScript
// (c)2004 Dan Gronitz
//
// This code was for Programmer's Corner (http://www.programmers-corner.com/index.php)
// and can be used freely for personal (non-commercial) use as long as this notice
// remains with the code.
//
function greet_time(){
now = new Date();
hour = now.getHours();
switch(hour){
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
case 11:
document.write("Good morning!");
break;
case 12:
case 13:
case 14:
case 15:
case 16:
document.write("Good afternoon!");
break;
case 17:
case 18:
case 19:
case 20:
case 21:
case 22:
case 23:
document.write("Good evening!");
break;
default:
document.write("Good day!");
break;
}
}
</script>

WEB DESIGN INDIA
42 B Malviya Nagar , New Delhi-110017

Skype: manmeetsi
Email: support.webdesignindia@gmail.com
Tel: 91-011-40502005, 9810067295

 















 


© 2008-2009 dotnet4all.com