aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/beforeunloadevent/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'files/fr/web/api/beforeunloadevent/index.md')
-rw-r--r--files/fr/web/api/beforeunloadevent/index.md103
1 files changed, 45 insertions, 58 deletions
diff --git a/files/fr/web/api/beforeunloadevent/index.md b/files/fr/web/api/beforeunloadevent/index.md
index 4a74d1689d..36cdf6e011 100644
--- a/files/fr/web/api/beforeunloadevent/index.md
+++ b/files/fr/web/api/beforeunloadevent/index.md
@@ -6,88 +6,75 @@ tags:
- Reference
translation_of: Web/API/BeforeUnloadEvent
---
-<p>{{APIRef}}</p>
+{{APIRef}}
-<p>L'évènement <strong><code>beforeunload</code></strong> est déclenché quand la fenêtre, le document et ses ressources sont sur le point d'être déchargées.</p>
+L'évènement **`beforeunload`** est déclenché quand la fenêtre, le document et ses ressources sont sur le point d'être déchargées.
-<p>Si une chaine non vide est assignée à la propriété <code>returnValue</code> de l'évènement, une boite de confirmation apparait pour demander à l'utilisateur de valider le changement d'adresse (voir les exemples ci-dessous). Si aucune valeur n'est fournise, l'évènement est traité silencieusement. Certaines implantations ne demandent confirmation que si le cadre ou tout cadre embarqué reçoit une action utilisateur. Voir {{anch("Browser compatibility")}} pour plus d'informations.</p>
+Si une chaine non vide est assignée à la propriété `returnValue` de l'évènement, une boite de confirmation apparait pour demander à l'utilisateur de valider le changement d'adresse (voir les exemples ci-dessous). Si aucune valeur n'est fournise, l'évènement est traité silencieusement. Certaines implantations ne demandent confirmation que si le cadre ou tout cadre embarqué reçoit une action utilisateur. Voir {{anch("Browser compatibility")}} pour plus d'informations.
-<p>{{InheritanceDiagram(600, 120)}}</p>
+{{InheritanceDiagram(600, 120)}}
<table class="properties">
- <tbody>
- <tr>
- <td><strong>Bouillonne</strong></td>
- <td>No</td>
- </tr>
- <tr>
- <td><strong>Annulable</strong></td>
- <td>Yes</td>
- </tr>
- <tr>
- <td><strong>Cibles</strong></td>
- <td>defaultView</td>
- </tr>
- <tr>
- <td><strong>Interface</strong></td>
- <td>{{domxref("Event")}}</td>
- </tr>
- </tbody>
+ <tbody>
+ <tr>
+ <td><strong>Bouillonne</strong></td>
+ <td>No</td>
+ </tr>
+ <tr>
+ <td><strong>Annulable</strong></td>
+ <td>Yes</td>
+ </tr>
+ <tr>
+ <td><strong>Cibles</strong></td>
+ <td>defaultView</td>
+ </tr>
+ <tr>
+ <td><strong>Interface</strong></td>
+ <td>{{domxref("Event")}}</td>
+ </tr>
+ </tbody>
</table>
-<h2 id="Exemples">Exemples</h2>
+## Exemples
-<pre class="brush:js;">window.addEventListener("beforeunload", function(event) {
+```js
+window.addEventListener("beforeunload", function(event) {
event.returnValue = "\o/";
});
// est équivalent à
window.addEventListener("beforeunload", function(event) {
event.preventDefault();
-});</pre>
+});
+```
-<p>Les navigateurs basés sur WebKit ne suivent pas la spécification concernant la demande de confirmation. Un exemple similaire fonctionnant sur presque tous les navigateurs serait plutôt comme :</p>
+Les navigateurs basés sur WebKit ne suivent pas la spécification concernant la demande de confirmation. Un exemple similaire fonctionnant sur presque tous les navigateurs serait plutôt comme :
-<pre class="brush: js">window.addEventListener("beforeunload", function (e) {
+```js
+window.addEventListener("beforeunload", function (e) {
var confirmationMessage = "\o/";
(e || window.event).returnValue = confirmationMessage; // Gecko + IE
return confirmationMessage; /* Safari, Chrome, and other
* WebKit-derived browsers */
-});</pre>
-
-<h2 id="Spécifications">Spécifications</h2>
-
-<table class="standard-table">
- <tbody>
- <tr>
- <th scope="col">Spécification</th>
- <th scope="col">État</th>
- <th scope="col">Commentaire</th>
- </tr>
- <tr>
- <td>{{SpecName("HTML WHATWG", "browsing-the-web.html#the-beforeunloadevent-interface", "BeforeUnloadEvent")}}</td>
- <td>{{Spec2("HTML WHATWG")}}</td>
- <td>Définition initiale</td>
- </tr>
- </tbody>
-</table>
+});
+```
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
+## Spécifications
-<div>
+| Spécification | État | Commentaire |
+| -------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------- | ------------------- |
+| {{SpecName("HTML WHATWG", "browsing-the-web.html#the-beforeunloadevent-interface", "BeforeUnloadEvent")}} | {{Spec2("HTML WHATWG")}} | Définition initiale |
+## Compatibilité des navigateurs
-<p>{{Compat("api.BeforeUnloadEvent")}}</p>
-</div>
+{{Compat("api.BeforeUnloadEvent")}}
-<h2 id="Voir_aussi">Voir aussi</h2>
+## Voir aussi
-<ul>
- <li>{{Event("DOMContentLoaded")}}</li>
- <li>{{Event("readystatechange")}}</li>
- <li>{{Event("load")}}</li>
- <li>{{Event("beforeunload")}}</li>
- <li>{{Event("unload")}}</li>
- <li><a href="http://www.whatwg.org/specs/web-apps/current-work/#prompt-to-unload-a-document">Unloading Documents — Prompt to unload a document</a></li>
-</ul>
+- {{Event("DOMContentLoaded")}}
+- {{Event("readystatechange")}}
+- {{Event("load")}}
+- {{Event("beforeunload")}}
+- {{Event("unload")}}
+- [Unloading Documents — Prompt to unload a document](http://www.whatwg.org/specs/web-apps/current-work/#prompt-to-unload-a-document)