+ 1

WiFi stuff

Hello, I want to write something that will check if I am connected to the internet, but I don’t really know what I’m doing... I found this method method online somewhere: if(navigator.online == true) { console.log(true)} else {console.log(false);} I’m not sure if this is working or not(or even working in the way I had intended), but I was curious as to how someone else would do it.

16th Apr 2018, 3:25 PM
Ian
2 ответов
+ 3
Making a xhr request and check its response status. It's onLine btw. This is old but there's online and offline event listeners. window.ononline = function();
16th Apr 2018, 3:53 PM
Toni Isotalo
Toni Isotalo - avatar
0
Awesome thx
16th Apr 2018, 4:04 PM
Ian