问题描述
我有一个要测试ping的HTML页面.我希望用户连接到该网站,并在主页上获得从计算机到特定服务器的往返结果.
I have an HTML page which I want to test a ping from.I want a user to connect to the website and in the main page he will get a result of the round trip from his computer to a specific server.
我应该使用"Ping"吗?我听说过一种叫做适用ping的东西,但这是我需要建立自己的东西,我不知道该怎么做.请帮助
Should I use "Ping"?I heard about something called applicable ping but it's something that I need to build myself and I don't know how..Please help
推荐答案
Ping只是请求和响应之间的延迟度量.正如Havenard所说,虽然ping实际上是基于ICMP的,但是您可以使用HTML/JS进行模拟,但是由于处理水平较高,它会增加一些延迟.
Ping is just the measure of delay between a request and response. Though ping is realybased on ICMP as stated by Havenard, you can simulate this using HTML/JS but it will add a bit of delay because of processing in the high levels.
ping-server.html
(服务器端)ping-server.html
(Server side)hello
ping-client.html
(客户端/在使用jQuery/js的浏览器中)ping-client.html
(Client side/In the browser using jQuery/js)<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
var ping = new Date;
$.ajax({
url: "ping-server.html",
cache:false,
success: function(output){
ping = new Date - ping;
Console.log("Ping/Latency: " + ping);
}
});
</script>
</head>
</html>
这篇关于从浏览器Ping的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!