The JavaScript Programming Language

Greetings Example Program


Click below to go directly to a specific section:
Description| Source Code| Sample Run

Description

Displays a different greeting depending on the time.

Source Code


<HTML>
<HEAD>
<TITLE>Greetings With JavaScript</TITLE>
</HEAD>
<BODY>
<SCRIPT>
<!--
var dateDate = new Date()  // Date-i-fy that number
var strDate = "" + dateDate
var strTime = strDate.substring(11,16)
var strGreating = ""
if (strTime < "12:00")
{
	strGreating = "Good morning welcome to the "
}
if (strTime > "12:00")
{
	if (strTime < "17:00")
	{
		strGreating = "Good afternoon welcome to the "
	}
	else{
		strGreating = "Good evening welcome to the "
	}
}


document.write(strGreating + "JavaScript web page")
//-->
</SCRIPT>

</BODY>
</HTML>


Sample Run


[Back] [Home]

Last Modified: 01:40 PM on 12/09/1997