-
Notifications
You must be signed in to change notification settings - Fork 0
/
Assignment2.html
55 lines (48 loc) · 1.44 KB
/
Assignment2.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<html>
<head>
<script type = "text/javascript">
function timeOfDay()
{
var myDate = new Date();
var myHour = myDate.getHours();
var myColor = "";
var myMessage = "";
if ( myHour >= 5 && myHour <= 11)
{
myMessage = 'You have reached this site in the morning';
myColor = 'yellow';
document.getElementById("myImage").innerHTML='<img src="morningimage.jpg" alt="morning">';
}
else if (myHour >= 12 && myHour <=17)
{
myMessage = 'You have reached this site in the afternoon';
myColor = 'green';
document.getElementById("myImage").innerHTML = '<img src="afternoonimage.png" alt="afternoon">';
}
else if (myHour >= 18 && myHour <=22)
{
myMessage = 'You have reached this site in the evening';
myColor = 'red';
document.getElementById("myImage").innerHTML = '<img src="eveningimage.png" alt="evening">';
}
else
{
myMessage = 'You have reached this site at night';
myColor ='blue';
document.getElementById("myImage").innerHTML = '<img src="nightimage.jpg" alt="night">';
}
document.bgColor = myColor;
document.getElementById("myMessage").innerHTML = myMessage;
}
</script>
<style>
</style>
</head>
<body onLoad = timeOfDay();>
<div id="myDiv">
<p id="myMessage"></p>
</div>
<div id="myImage">
</div>
</body>
</html>