Saturday, 15 June 2013

Write a script that displays the message “Good Morning”, “Good afternoon” and “Good Evening” in a separate window according to time of the day?



<html>
<head><title>date Example</title>
<script language="Javascript">
function wish()
{
d=new Date();
hr=d.getHours();
if(hr<12)
alert("good morning");
else if(hr>=12 && hr<17)
alert("good afternoon");
else
alert("good evening");
}
</script>
</head>
<body>
<input type= "button" value="test" OnClick="wish()">
<hr>
</body>
</html>

No comments:

Post a Comment