Checking if the Internet and a particular site are up in JavaScript/AJAX

前端 未结 3 1134
礼貌的吻别
礼貌的吻别 2021-01-24 17:09

I have a page which runs locally on my device, and I would like to use AJAX or normal JavaScript to check if the device is connected to the Internet and if a pa

3条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-24 17:41

    There is basic support for

    navigator.online
    //Events
    window.onOnline
    window.onOffline
    

    on desktop browsers and support on Android. This might not completely answer your question, but I thought its worth sharing anyway :)

提交回复
热议问题