Detect internet connection

    0

    0

    Ahmed Barrada

    Check the console below for results:

    initially on line

    Library: vue

    console.log('Initially ' + (window.navigator.onLine ? 'on' : 'off') + 'line');
    
    window.addEventListener('online', () => console.log('Became online'));
    window.addEventListener('offline', () => console.log('Became offline'));
    
    document.getElementById('statusCheck').addEventListener('click',
    
    <button id="statusCheck">Click to check the <tt>window.navigator.onLine</tt> property</button><br /><br />
    Check the console below for results:
    
      // ORRRR NUXT WAY
      https://stackoverflow.com/questions/66651204/how-to-detect-internet-connection-on-off-in-vuejs-nuxtjs
                                                            
      //ORRRR                                                   
    
    https://medium.com/@android.bks/monitoring-the-internet-connection-in-your-vue-app-a9d3f3b5bbb2
                                                            
                                                            
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.