javascriptofflineapps

navigator.onLine still true when turning off WiFi, false when set "work offline" in browser


navigator.onLine is still returning true when I turn off Wi-Fi (Airport on my notebook in OS X). This is counterintuitive behavior. But when I set "work offline" in a browser like Firefox, it correctly returns false. Is this expected?

alert(navigator.onLine ? "online" : "offline");

Solution

  • Yes. The browser doesn't provide network connectivity information to the page, but rather uses Work Offline's status as the value.