Check if connected to a network; jQuery

后端 未结 7 1035
执笔经年
执笔经年 2020-12-13 20:37

I have searched through StackOverflow and have seen various topics on how to do this, but nothing that really pertains to my particular situation. I am writing (for a class)

7条回答
  •  猫巷女王i
    2020-12-13 21:04

    Using window.navigator.onLine is inherantly unreliable, because the user might be connected to a network, but that network could not have internet access.

    However, here is a barebones example

    
    
     
      Online status
      
     
     
      

    The network is: (state unknown)

    See the fiddle in action: http://jsfiddle.net/3rRWK/

提交回复
热议问题