From 065446e478a176c2fcec5b84eb2d528ab13b7cb4 Mon Sep 17 00:00:00 2001 From: Will Bamberg Date: Fri, 4 Mar 2022 16:32:24 -0800 Subject: [PATCH] Fix issue 13505: delete offline events doc --- files/en-us/_redirects.txt | 9 +- files/en-us/_wikihistory.json | 32 ----- .../online_and_offline_events/index.md | 123 ------------------ 3 files changed, 5 insertions(+), 159 deletions(-) delete mode 100644 files/en-us/web/api/navigator/online_and_offline_events/index.md diff --git a/files/en-us/_redirects.txt b/files/en-us/_redirects.txt index aa9435383bde207..689eb80e72af58b 100644 --- a/files/en-us/_redirects.txt +++ b/files/en-us/_redirects.txt @@ -6254,9 +6254,9 @@ /en-US/docs/Netscape_Gecko_User_Agent_Strings /en-US/docs/Web/HTTP/Headers/User-Agent/Firefox /en-US/docs/Node_server_without_framework /en-US/docs/Learn/Server-side/Node_server_without_framework /en-US/docs/Notable_bugs_fixed_in_Firefox_3 /en-US/docs/Mozilla/Firefox/Releases/3/Notable_bugs_fixed -/en-US/docs/Online/Offline_Events /en-US/docs/Web/API/Navigator/Online_and_offline_events -/en-US/docs/Online_Offline_Events /en-US/docs/Web/API/Navigator/Online_and_offline_events -/en-US/docs/Online_and_offline_events /en-US/docs/Web/API/Navigator/Online_and_offline_events +/en-US/docs/Online/Offline_Events /en-US/docs/Web/API/Navigator/onLine +/en-US/docs/Online_Offline_Events /en-US/docs/Web/API/Navigator/onLine +/en-US/docs/Online_and_offline_events /en-US/docs/Web/API/Navigator/onLine /en-US/docs/OpenWebApps /en-US/docs/Web/Progressive_web_apps /en-US/docs/OpenWebDemos /en-US/docs/Web/Demos /en-US/docs/Optimizing_Your_Pages_for_Speculative_Parsing /en-US/docs/Glossary/speculative_parsing @@ -8515,6 +8515,7 @@ /en-US/docs/Web/API/Navigator.vendor /en-US/docs/Web/API/Navigator/vendor /en-US/docs/Web/API/Navigator.vendorSub /en-US/docs/Web/API/Navigator/vendorSub /en-US/docs/Web/API/Navigator.vibrate /en-US/docs/Web/API/Navigator/vibrate +/en-US/docs/Web/API/Navigator/Online_and_offline_events /en-US/docs/Web/API/Navigator/onLine /en-US/docs/Web/API/Navigator/getVRDevices /en-US/docs/Web/API/Navigator/getVRDisplays /en-US/docs/Web/API/Navigator/mediaDevices.getUserMedia /en-US/docs/Web/API/MediaDevices/getUserMedia /en-US/docs/Web/API/Navigator/mediaDevices/enumerateDevices /en-US/docs/Web/API/MediaDevices/enumerateDevices @@ -8547,7 +8548,7 @@ /en-US/docs/Web/API/NavigatorLanguage/languages /en-US/docs/Web/API/Navigator/languages /en-US/docs/Web/API/NavigatorOnLine /en-US/docs/Web/API/Navigator /en-US/docs/Web/API/NavigatorOnLine.onLine /en-US/docs/Web/API/Navigator/onLine -/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events /en-US/docs/Web/API/Navigator/Online_and_offline_events +/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events /en-US/docs/Web/API/Navigator/onLine /en-US/docs/Web/API/NavigatorOnLine/onLine /en-US/docs/Web/API/Navigator/onLine /en-US/docs/Web/API/NavigatorPlugins /en-US/docs/Web/API/Navigator /en-US/docs/Web/API/NavigatorPlugins.javaEnabled /en-US/docs/Web/API/Navigator/javaEnabled diff --git a/files/en-us/_wikihistory.json b/files/en-us/_wikihistory.json index f758864f8560d14..a43656ec6da9f37 100644 --- a/files/en-us/_wikihistory.json +++ b/files/en-us/_wikihistory.json @@ -61218,38 +61218,6 @@ "Jeremie" ] }, - "Web/API/Navigator/Online_and_offline_events": { - "modified": "2020-09-15T12:54:20.249Z", - "contributors": [ - "OtterOne", - "chrisdavidmills", - "torazaburo", - "edwardcasbon", - "artistics-weddings", - "schmod", - "maxbarrett", - "kazaf", - "PierreBergamin", - "jsx", - "Jeremie", - "kscarfone", - "teoli", - "HaNdTriX", - "lmorchard", - "DavidWalsh", - "jswisher", - "john_smith", - "ethertank", - "grendel", - "Sheppy", - "sebmozilla", - "Nickolay", - "Mgjbot", - "Leandro Mercês Xavier", - "BenoitL", - "Jresig" - ] - }, "Web/API/Navigator/activeVRDisplays": { "modified": "2020-10-15T21:46:04.268Z", "contributors": [ diff --git a/files/en-us/web/api/navigator/online_and_offline_events/index.md b/files/en-us/web/api/navigator/online_and_offline_events/index.md deleted file mode 100644 index acea3ae8b6b99a0..000000000000000 --- a/files/en-us/web/api/navigator/online_and_offline_events/index.md +++ /dev/null @@ -1,123 +0,0 @@ ---- -title: Online and offline events -slug: Web/API/Navigator/Online_and_offline_events -tags: - - AJAX - - DOM - - HTML5 - - Intermediate - - NeedsUpdate - - Offline web applications - - Web Development ---- -Some browsers implement [Online/Offline events](https://www.whatwg.org/specs/web-apps/current-work/#offline) from the [WHATWG Web Applications 1.0 specification](https://www.whatwg.org/specs/web-apps/current-work/). - -## Overview - -In order to build a good offline-capable web application, you need to know when your application is actually offline. You also need to know when your application has returned to an 'online' status again. Effectively, the requirements break down as such: - -1. You need to know when the user comes back online, so that you can re-synchronize with the server. -2. You need to know when the user is offline, so that you can queue your server requests for a later time. - -It is this process that online/offline events help to simplify. - -Unfortunately, these events aren't fully reliable. If you need greater reliability, or if the API isn't implemented in the browser, you can use other signals to detect if you are offline including using service workers and [responses from XMLHttpRequest](http://www.html5rocks.com/en/mobile/workingoffthegrid.html#toc-xml-http-request). - -## API - -### `navigator.onLine` - -[`navigator.onLine`](/en-US/docs/DOM/window.navigator.onLine) is a property that maintains a `true`/`false` value (`true` for online, `false` for offline). - -This property is updated whenever the user switches into "Offline Mode" (File → Work Offline in Firefox). Additionally, this property should update whenever a browser is no longer capable of connecting to the network. According to the [specification](https://www.whatwg.org/specs/web-apps/current-work/#offline): - -> The `navigator.onLine` attribute must return false if the user agent will not contact the network when the user follows links or when a script requests a remote page (or knows that such an attempt would fail)... - -Firefox 2 updates this property when switching to/from the browser's Offline mode. [Firefox 41](/en-US/Firefox/Releases/41#Miscellaneous) updates this property also when the OS reports a change in network connectivity on Windows, Linux, and OS X. - -This property existed in older versions of Firefox and Internet Explorer (the specification based itself off of these prior implementations), so you can begin using it immediately. Network status autodetection was implemented in Firefox 2. - -### "`online`" and "`offline`" events - -[Firefox 3](/en-US/docs/Firefox_3_for_developers) introduces two new events: "[`online`](/en-US/docs/Web/API/document.ononline)" and "[`offline`](/en-US/docs/Web/API/document.onoffline)". These two events are fired on the `` of each page when the browser switches between online and offline mode. Additionally, the events bubble up from `document.body`, to `document`, ending at `window`. Both events are non-cancellable (you can't prevent the user from coming online, or going offline). - -[Firefox 41](/en-US/Firefox/Releases/41#Miscellaneous) fires these events when the OS reports a change in network connectivity on Windows, Linux, and OS X. - -You can register listeners for these events in a few familiar ways: - -- using [`addEventListener`](/en-US/docs/DOM/element.addEventListener) on the `window`, `document`, or `document.body` -- by setting the `.ononline` or `.onoffline` properties on `document` or `document.body` to a JavaScript `Function` object. (**Note:** using `window.ononline` or `window.onoffline` will not work for compatibility reasons.) -- by specifying `ononline="..."` or `onoffline="..."` attributes on the `` tag in the HTML markup. - -## Example - -There's [a simple test case](https://bugzilla.mozilla.org/attachment.cgi?id=220609) that you can run to verify that the events are working (does not work in Chrome due to attaching the event listener to document.body). - -Here's the JavaScript part: - -```js -window.addEventListener('load', function() { - var status = document.getElementById("status"); - var log = document.getElementById("log"); - - function updateOnlineStatus(event) { - var condition = navigator.onLine ? "online" : "offline"; - - status.className = condition; - status.innerHTML = condition.toUpperCase(); - - log.insertAdjacentHTML("beforeend", "Event: " + event.type + "; Status: " + condition); - } - - window.addEventListener('online', updateOnlineStatus); - window.addEventListener('offline', updateOnlineStatus); -}); -``` - -A touch of CSS - -```css -#status { - position: fixed; - width: 100%; - font: bold 1em sans-serif; - color: #FFF; - padding: 0.5em; -} - -#log { - padding: 2.5em 0.5em 0.5em; - font: 1em sans-serif; -} - -.online { - background: green; -} - -.offline { - background: red; -} -``` - -And the corresponding HTML: - -```html -
-
-

This is a test

-``` - -Here's the live result - -{{ EmbedLiveSample('Example', '100%', '150') }} - -## Notes - -If the API isn't implemented in the browser, you can use other signals to detect if you are offline including using service workers and [responses from XMLHttpRequest](http://www.html5rocks.com/en/mobile/workingoffthegrid.html#toc-xml-http-request). - -## References - -- ['Online/Offline events' section from the WHATWG Web Applications 1.0 Specification](https://www.whatwg.org/specs/web-apps/current-work/#offline) -- [The bug tracking online/offline events implementation in Firefox](https://bugzilla.mozilla.org/show_bug.cgi?id=336359) and a [follow-up](https://bugzilla.mozilla.org/show_bug.cgi?id=336682) -- [A simple test case](https://bugzilla.mozilla.org/attachment.cgi?id=220609) -- [An explanation of Online/Offline events](http://ejohn.org/blog/offline-events/)