Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/440.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用telnet在javascript中调用变量_Javascript_Html_Css_Telnet - Fatal编程技术网

如何使用telnet在javascript中调用变量

如何使用telnet在javascript中调用变量,javascript,html,css,telnet,Javascript,Html,Css,Telnet,我有一个由多个页面组成的网站。我的网站未托管,通过xampp localhost查看。我想知道如何调用变量,在接收到Mute时将颜色更改为红色,在从远程telnet接收到MuteOn时将颜色更改为绿色,以显示下面标记为icon的图标代码。这也是我当前的telnet javascript连接代码。我最终希望我的server.js具有接收命令的功能,然后将它们实现到我的网页上 Server.js: // Include Nodejs' net module. const Net = require(

我有一个由多个页面组成的网站。我的网站未托管,通过xampp localhost查看。我想知道如何调用变量,在接收到Mute时将颜色更改为红色,在从远程telnet接收到MuteOn时将颜色更改为绿色,以显示下面标记为icon的图标代码。这也是我当前的telnet javascript连接代码。我最终希望我的server.js具有接收命令的功能,然后将它们实现到我的网页上

Server.js:

// Include Nodejs' net module.
const Net = require('net');
// The port on which the server is listening.
const port = 50000;
// Use net.createServer() in your code. This is just for illustration purpose.
// Create a new TCP server.
const server = new Net.Server();
// The server listens to a socket for a client to make a connection request.
// Think of a socket as an end point.
server.listen(port, function() {
    console.log(`Server listening for connection requests on socket localhost:${port}`.);
});
// When a client requests a connection with the server, the server creates a new
// socket dedicated to that client.
server.on('connection', function(socket) {
    console.log('A new connection has been established.');
    // Now that a TCP connection has been established, the server can send data to
    // the client by writing to its socket.
    socket.write('Hello, client.');
    // The server can also receive data from the client by reading from its socket.
    socket.on('data', function(chunk) {
        console.log(`Data received from client: ${chunk.toString()`.});
    });
    // When the client requests to end the TCP connection with the server, the server
    // ends the connection.
    socket.on('end', function() {
        console.log('Closing connection with the client');
    });
    // Don't forget to catch error, for your own sake.
    socket.on('error', function(err) {
        console.log(`Error: ${err}`);
    });
});
图标代码:

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<script src="https://kit.fontawesome.com/a076d05399.js"></script>
</head>
<body>

<div class="flex-w flex-c-m p-t-5 p-b-0">
<a href="#" class="flex-c-m how-social trans-04 m-r-50 m-l-50 m-b-5">
<i class='fas fa-volume-up' style='font-size:95px;color:white'></i>
</a>

<a href="#" class="flex-c-m how-social trans-04 m-r-50 m-l-50 m-b-5">
<i class='fas fa-microphone' style='font-size:95px;color:white'></i>
</a>

<a href="#" class="flex-c-m how-social trans-04 m-r-50 m-l-50 m-b-5">
<i class='fas fa-phone-volume' style='font-size:95px;color:white'></i>
</a>

<a href="#" class="flex-c-m how-social trans-04 m-r-50 m-l-50 m-b-5">
<i class='fas fa-video' style='font-size:95px;color:white'></i>
</a>
</div>
</div>

</body>
</html>


我在设计这个网页时使用了html、css和javascript。我对使用telnet相当陌生,因此非常感谢您提供的所有信息。谢谢

您需要像express这样的东西来调整和提供HTML。Telnet使用的是不同于HTTP协议的TCP协议。

因此,您的站点的操作根本不涉及HTTP和浏览器?是的,我通过本地主机在google chrome上运行它。希望这对@avivloy有帮助。你需要像express这样的东西来twick和服务htmlNo问题。我应该补充答案吗?是的,请@AvivLo