我需要在单个html页面中获得SSID名称。我需要用于登录,如果有人在某个地点连接到特定的WI-FI网络。
因此,我需要一个非常简单的方法来获得当前的SSID名称的连接。我对window.navigator.connection进行了一些尝试,这是我使用的下一个示例,用于确定连接是with还是蜂窝式连接,它是有效的:
var connection = window.navigator.connection ||
window.navigator.mozConnection ||
null;
if (connection === null) {
document.getElementById('ni-unsupported').classList.remove('hidden');
} else if ('metered' in connection) {
document.getElementById('nio-supported').classList.remove('hidden');
[].slice.call(document.getElementsByClassName('old-api')).forEach(function(element) {
element.classList.remove('hidden');
});
var bandwidthValue = document.getElementById('b-value');
var meteredValue = document.getElementById('m-value');
connection.addEventListener('change', function(event) {
bandwidthValue.innerHTML = connection.bandwidth;
meteredValue.innerHTML = (connection.metered ? '' : 'not ') + 'metered';
});
connection.dispatchEvent(new Event('change'));
} else {
var typeValue = document.getElementById('t-value');
[].slice.call(document.getElementsByClassName('new-api')).forEach(function(element) {
element.classList.remove('hidden');
});
connection.addEventListener('typechange', function(event) {
typeValue.innerHTML = connection.type;
});
connection.dispatchEvent(new Event('typechange'));
}
因此,我想知道我是否可以使用window.navigator.connection来获取SSID名称或任何其他简单的方法
发布于 2021-12-04 01:41:26
如果用户连接到wi网络,我问题的解决方案可能是通过SSID名称检索IP地址。因为我需要检查他在某个地方的存在,这样我就知道WI网络(SSID)的名字了。所以,如果结果是某个IP地址,那就意味着那个人在那个地方。但我需要私人(本地)的WI-FI IP地址,而不是公共地址,所以如果有办法这样做的话,那就足够了。我在https://docs.oracle.com/javase/tutorial/networking/nifs/retrieving.html上发现了一些东西
The NetworkInterface class和get接口的名称getByName()
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class ListNIFs
{
public static void main(String args[]) throws SocketException {
Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
for (NetworkInterface netIf : Collections.list(nets)) {
out.printf("Display name: %s\n", netIf.getDisplayName());
out.printf("Name: %s\n", netIf.getName());
displaySubInterfaces(netIf);
out.printf("\n");
}
}
static void displaySubInterfaces(NetworkInterface netIf) throws SocketException {
Enumeration<NetworkInterface> subIfs = netIf.getSubInterfaces();
for (NetworkInterface subIf : Collections.list(subIfs)) {
out.printf("\tSub Interface Display name: %s\n", subIf.getDisplayName());
out.printf("\tSub Interface Name: %s\n", subIf.getName());
}
}
}```
So I wonder can I use this in single HTML page and how to do it if it is possible.
Or any other suggestionhttps://stackoverflow.com/questions/70208173
复制相似问题