Skip to content

Commit

Permalink
Move navigator.onLine section to a more logical place
Browse files Browse the repository at this point in the history
  • Loading branch information
annevk committed Nov 18, 2020
1 parent 1d7a44b commit 80336d0
Showing 1 changed file with 65 additions and 68 deletions.
133 changes: 65 additions & 68 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -85626,74 +85626,6 @@ interface <dfn>BeforeUnloadEvent</dfn> : <span>Event</span> {
or in multiple headers.</p>
</div>

<h4 id="navigator.online"><span id="browser-state">Browser state</span></h4>

<pre><code class="idl">interface mixin <dfn>NavigatorOnLine</dfn> {
readonly attribute boolean <span data-x="dom-navigator-onLine">onLine</span>;
};</code></pre>

<dl class="domintro">
<dt><var>self</var> . <code data-x="dom-navigator">navigator</code> . <code subdfn
data-x="dom-navigator-onLine">onLine</code></dt>

<dd>
<p>Returns false if the user agent is definitely offline (disconnected from the network).
Returns true if the user agent might be online.</p>

<p>The events <code data-x="event-online">online</code> and <code
data-x="event-offline">offline</code> are fired when the value of this attribute changes.</p>
</dd>
</dl>

<div w-nodev>

<p>The <dfn><code data-x="dom-navigator-onLine">navigator.onLine</code></dfn> 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), and must return true
otherwise.</p>

<p>When the value that would be returned by the <code
data-x="dom-navigator-onLine">navigator.onLine</code> attribute of a <code>Window</code> or
<code>WorkerGlobalScope</code> <var>global</var> changes from true to false, the user agent must
<span>queue a global task</span> on the <span>networking task source</span> given
<var>global</var> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-offline">offline</code> at <var>global</var>.</p>

<p>On the other hand, when the value that would be returned by the <code
data-x="dom-navigator-onLine">navigator.onLine</code> attribute of a <code>Window</code> or
<code>WorkerGlobalScope</code> <var>global</var> changes from false to true, the user agent must
<span>queue a global task</span> on the <span>networking task source</span> given
<var>global</var> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-online">online</code> at the <code>Window</code> or <code>WorkerGlobalScope</code>
object.</p>

</div>

<p class="note">This attribute is inherently unreliable. A computer can be connected to a network
without having Internet access.</p>

<div class="example">

<p>In this example, an indicator is updated as the browser goes online and offline.</p>

<pre><code class="html">&lt;!DOCTYPE HTML>
&lt;html lang="en">
&lt;head>
&lt;title>Online status&lt;/title>
&lt;script>
function updateIndicator() {
document.getElementById('indicator').textContent = navigator.onLine ? 'online' : 'offline';
}
&lt;/script>
&lt;/head>
&lt;body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
&lt;p>The network is: &lt;span id="indicator">(state unknown)&lt;/span>
&lt;/body>
&lt;/html></code></pre>

</div>




<h2 split-filename="webappapis" id="webappapis">Web application APIs</h2>
Expand Down Expand Up @@ -92826,6 +92758,71 @@ interface <dfn>Navigator</dfn> {
</div>


<h5 id="navigator.online"><span id="browser-state">Browser state</span></h5>

<pre><code class="idl">interface mixin <dfn>NavigatorOnLine</dfn> {
readonly attribute boolean <span data-x="dom-navigator-onLine">onLine</span>;
};</code></pre>

<dl class="domintro">
<dt><var>self</var> . <code data-x="dom-navigator">navigator</code> . <code subdfn
data-x="dom-navigator-onLine">onLine</code></dt>

<dd>
<p>Returns false if the user agent is definitely offline (disconnected from the network).
Returns true if the user agent might be online.</p>

<p>The events <code data-x="event-online">online</code> and <code
data-x="event-offline">offline</code> are fired when the value of this attribute changes.</p>
</dd>
</dl>

<div w-nodev>

<p>The <dfn><code data-x="dom-navigator-onLine">navigator.onLine</code></dfn> 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), and must return true
otherwise.</p>

<p>When the value that would be returned by the <code
data-x="dom-navigator-onLine">navigator.onLine</code> attribute of a <code>Window</code> or
<code>WorkerGlobalScope</code> <var>global</var> changes from true to false, the user agent must
<span>queue a global task</span> on the <span>networking task source</span> given
<var>global</var> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-offline">offline</code> at <var>global</var>.</p>

<p>On the other hand, when the value that would be returned by the <code
data-x="dom-navigator-onLine">navigator.onLine</code> attribute of a <code>Window</code> or
<code>WorkerGlobalScope</code> <var>global</var> changes from false to true, the user agent must
<span>queue a global task</span> on the <span>networking task source</span> given
<var>global</var> to <span data-x="concept-event-fire">fire an event</span> named <code
data-x="event-online">online</code> at the <code>Window</code> or <code>WorkerGlobalScope</code>
object.</p>

</div>

<p class="note">This attribute is inherently unreliable. A computer can be connected to a network
without having Internet access.</p>

<div class="example">
<p>In this example, an indicator is updated as the browser goes online and offline.</p>

<pre><code class="html">&lt;!DOCTYPE HTML>
&lt;html lang="en">
&lt;head>
&lt;title>Online status&lt;/title>
&lt;script>
function updateIndicator() {
document.getElementById('indicator').textContent = navigator.onLine ? 'online' : 'offline';
}
&lt;/script>
&lt;/head>
&lt;body onload="updateIndicator()" ononline="updateIndicator()" onoffline="updateIndicator()">
&lt;p>The network is: &lt;span id="indicator">(state unknown)&lt;/span>
&lt;/body>
&lt;/html></code></pre>
</div>


<h5 id="custom-handlers">Custom scheme handlers: the <code data-x="dom-navigator-registerProtocolHandler">registerProtocolHandler()</code> method</h5>

Expand Down

0 comments on commit 80336d0

Please sign in to comment.