Online/Offline Event Detection

    The attribute returns:

    Since many cases return true, you should treat with care situations of getting false positives, as we cannot always assume that value means that Electron can access the Internet. For example, in cases when the computer is running a virtualization software that has virtual Ethernet adapters in “always connected” state. Therefore, if you want to determine the Internet access status of Electron, you should develop additional means for this check.

    Example

    Starting with an HTML file index.html, this example will demonstrate how the navigator.onLine API can be used to build a connection status indicator.

    In order to mutate the DOM, create a renderer.js file that adds event listeners to the and 'offline' window events. The event handler sets the content of the <strong id='status'> element depending on the result of .

    renderer.js

    Finally, create a main.js file for main process that creates the window.

    After launching the Electron application, you should see the notification: