Share this Page URL
Help

Chapter 17. The Programmable Page: Addin... > Some JavaScript Examples - Pg. 200

The Programmable Page: Adding JavaScripts to Your Pages if (minuteValue < 10) minuteValue = "0" + minuteValue // Get the current hours hourValue = d.getHours() // Customize the greeting based on the current hours if (hourValue < 12) { greeting = "Good morning!" timeText = " at " + hourValue + ":" + minuteValue + " AM" } else if (hourValue == 12) { greeting = "Good afternoon!" timeText = " at " + hourValue + ":" + minuteValue + " PM" } else if (hourValue < 17) { greeting = "Good afternoon!" timeText = " at " + (hourValue-12) + ":" + minuteValue + " PM" } else { greeting = "Good evening!" timeText = " at " + (hourValue-12) + ":" + minuteValue + " PM" } // Write the greeting, the date, and the time to the page document.write(greeting + " It's " + dateText + timeText) //--> </SCRIPT> 200 Whew! That's some script! It works quite nicely, though, as you can see in Figure 17.6.