Files
RemoteControl/socketEnd/index.html
2024-09-27 01:09:52 +08:00

42 lines
899 B
HTML

<!DOCTYPE html>
<html>
<head>
<title>websocket</title>
</head>
<body>
<button>点我唤醒手机</button>
</body>
<script type="text/javascript">
// 浏览器提供 WebSocket 对象
var ws = new WebSocket("ws://120.27.144.174:8080/html");
// 发送
ws.onopen = function () {
console.log("Connection open ...");
};
ws.onmessage = function (evt) {
console.log("Received Message: " + evt.data);
};
document.querySelector("button").onclick = function () {
ws.send(
JSON.stringify({
type: 1,
data: {
// 大地中学 东北门
// Longitude: 117.325131,
// Latitude: 31.793141,
// 信旺华府俊苑14栋
// Longitude: 117.237326,
// Latitude: 31.830978,
},
})
);
};
</script>
</html>