blob: 98bd7cc28f535a0f4ca890735ac96cfd672b3642 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
---
title: 'Window: Evenement offline'
slug: Web/API/Window/offline_event
tags:
- API
- Event
- Offline
- Reference
- Window
translation_of: Web/API/Window/offline_event
---
{{APIRef}}
L'événement **`offline`** de l'interface {{domxref("Window")}} se déclenche lorsque le navigateur perd la connexion au réseau et la valeur de {{domxref("Navigator.onLine")}} bascule à `false`.
<table class="properties">
<tbody>
<tr>
<th scope="row">Bulles</th>
<td>Non</td>
</tr>
<tr>
<th scope="row">Annulable</th>
<td>Non</td>
</tr>
<tr>
<th scope="row">Interface</th>
<td>{{domxref("Event")}}</td>
</tr>
<tr>
<th scope="row">Propriété de gestionnaire d'événements</th>
<td>
{{domxref("GlobalEventHandlers.onoffline", "onoffline")}}
</td>
</tr>
</tbody>
</table>
## Exemples
```js
//version addEventListener
window.addEventListener('offline', (event) => {
console.log("La Connexion au réseau est perdu.");
});
// onoffline version
window.onoffline = (event) => {
console.log("La Connexion au réseau a été perdue.");
};
```
## Spécifications
| Spécification | Statut |
| ---------------------------------------------------------------------------------------------------- | -------------------------------- |
| {{SpecName('HTML WHATWG', "indices.html#event-offline", "offline event")}} | {{Spec2('HTML WHATWG')}} |
## Compatibilité des Navigateurs
{{Compat("api.Window.offline_event")}}
## Voir également
- [`online`](/en-US/docs/Web/API/Window/online_event)
|