-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
110 lines (107 loc) · 2.58 KB
/
index.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<div class="raw">
<h1>601 air conditioning</h1>
<div class="raw">
<input type="button" class="on" value="ON" onclick="on()">
</div>
<div class="raw">
<input type="button" class="off" value="OFF" onclick="off()">
</div>
</div>
</body>
</html>
<style type="text/css">
.raw{
max-width: 1140px;
margin: 0 auto;
}
h1{
display: block;
color: darkslategray;
margin:2px auto;
text-align: center;
padding-bottom: 20px;
font-size: 80px ;
}
.on{
margin: 50px 35%;
width: 30%;
height: 100px;
color: black;
background: aqua;
border: 1;
font-size: 50px;
}
.off{
margin: 0 35%;
width:30%;
height: 100px;
color: black;
background: crimson;
border: 1;
font-size: 50px;
}
@media only screen and (max-width:480px){
h1{
font-size: 35px;
padding-bottom: 0;
}
.on,
.off{
height: 70px;
margin: 20px 30%;
width: 40%;
font-size: 25px;
}
}
</style>
<script type="text/jscript">
function on()
{
var url = "http://换成你的esp8266的IP地址/on";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("txtState").innerHTML = xmlhttp.responseText;
}
}
xmlhttp.open("POST", url, true);
xmlhttp.send();
}
function off()
{
var url = "http://换成你的esp8266的IP地址/off";
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function ()
{
if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
document.getElementById("txtState").innerHTML = xmlhttp.responseText;
}
},
xmlhttp.open("POST", url, true);
xmlhttp.send();
}
</script>