Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/31.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
javascript navigator.onLine仅检查与internet设备连接的系统,而不是internet_Javascript_Angular - Fatal编程技术网

javascript navigator.onLine仅检查与internet设备连接的系统,而不是internet

javascript navigator.onLine仅检查与internet设备连接的系统,而不是internet,javascript,angular,Javascript,Angular,我使用了navigator.onLine来确定我的系统是否连接到internet,但它只评估系统是否连接到wifi或其他设备。假设系统与wifi连接,但没有互联网。然后返回true。 有什么解决办法吗?或者我做错了什么?下面是它的工作原理。 navigator.online检查设备是否连接到网络。 当使用实时服务器时,让它成为一个真实的网络LAN或WIFI(有或没有internet)或一些虚拟网络 您可以尝试使用Firefox浏览器模拟脱机,然后选择work offline,您将看到naviga

我使用了
navigator.onLine
来确定我的系统是否连接到internet,但它只评估系统是否连接到wifi或其他设备。假设系统与wifi连接,但没有互联网。然后返回
true
。 有什么解决办法吗?或者我做错了什么?

下面是它的工作原理。 navigator.online检查设备是否连接到网络。 当使用实时服务器时,让它成为一个真实的网络LAN或WIFI(有或没有internet)或一些虚拟网络


您可以尝试使用Firefox浏览器模拟脱机,然后选择work offline,您将看到navigator。online返回false

这不是JavaScript问题,而是一般的网络问题。您必须尝试从internet加载页面,以确定是否可以访问该页面。