Hitu Bansal
Hitu Bansal

Reputation: 3137

window.Connection on Chrome using ionic Framework

I am trying t. heo check if network connection is exist or not. here is some code

 if (window.Connection) {
        if (navigator.connection.type == Connection.NONE) {
            window.localStorage.setItem("connectionType", '0');
        } else {
            window.localStorage.setItem("connectionType", '1');
        }
    } else {
        alert("function doesnot run");
    }

It is working fine on device and emulator. Can we check same on web browser

Thanks

Upvotes: 0

Views: 208

Answers (1)

Manish Kr. Shukla
Manish Kr. Shukla

Reputation: 4477

Answer to your question is navigator.onLine. It returns true if you are connected to some network..

Here's a snap from my browser

enter image description here

Upvotes: 1

Related Questions