Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detecting offline mode; navigator.onLine not working #77

Open
Budsy opened this issue Sep 6, 2020 · 1 comment
Open

Detecting offline mode; navigator.onLine not working #77

Budsy opened this issue Sep 6, 2020 · 1 comment

Comments

@Budsy
Copy link

Budsy commented Sep 6, 2020

My PWA is working offline just fine, but I want to detect offline operation in javascript so I can display the status on a page, window.navigator.onLine doesn't seem to give the online status correctly. It will return true even if offline and disconnected. Is there a way to get offline/online status reliably?

@Budsy
Copy link
Author

Budsy commented Sep 8, 2020

To respond to my own post, further research on this shows that navigator.onLine is not consistently implemented across browsers, and explains my problem. But while on this, does anyone know a reliable way to check connectivity? I'm trying to make sure my program does not try to do certain ajax calls when the app is disconnected. Using ajax itself to check for connectivity generally makes for bad performance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant