aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/windoweventhandlers/onbeforeunload/index.md
diff options
context:
space:
mode:
Diffstat (limited to 'files/fr/web/api/windoweventhandlers/onbeforeunload/index.md')
-rw-r--r--files/fr/web/api/windoweventhandlers/onbeforeunload/index.md49
1 files changed, 49 insertions, 0 deletions
diff --git a/files/fr/web/api/windoweventhandlers/onbeforeunload/index.md b/files/fr/web/api/windoweventhandlers/onbeforeunload/index.md
new file mode 100644
index 0000000000..638f24c27b
--- /dev/null
+++ b/files/fr/web/api/windoweventhandlers/onbeforeunload/index.md
@@ -0,0 +1,49 @@
+---
+title: window.onbeforeunload
+slug: Web/API/WindowEventHandlers/onbeforeunload
+translation_of: Web/API/WindowEventHandlers/onbeforeunload
+---
+<h2 id="Sommaire">Résumé</h2>
+
+<p>Le gestionnaire d'événement <code><strong>WindowEventHandlers.onbeforeunload</strong></code> contient le code exécuté lorsque l'évènement {{event("beforeunload")}} est envoyé. Cet événement se déclenche lorsque la fenêtre est sur le point de recharger ses ressources.</p>
+
+<h2 id="Syntaxe">Syntaxe</h2>
+
+<pre class="brush: html">&lt;element beforeunload="funcRef(event);" /&gt;</pre>
+
+<pre class="brush: html">&lt;script type="text/javascript"&gt;
+ window.onbeforeunload = funcRef
+&lt;/script&gt;</pre>
+
+<ul>
+ <li>funcRef : Référence à une fonction appelée lorsque l'évènement se déclenche</li>
+</ul>
+
+<h2 id="Exemple">Exemple</h2>
+
+<pre class="brush: js">window.onbeforeunload = function (e) {
+ var e = e || window.event;
+
+ // For IE and Firefox
+ if (e) {
+ e.returnValue = 'Any string';
+ }
+
+ // For Safari
+ return 'Any string';
+};
+</pre>
+
+<h2 id="EventProperty">Propriétés de l'objet <strong>event</strong></h2>
+
+<pre>returnValue</pre>
+
+<ul>
+ <li>Applique ou récupère la valeur de retour de l'évènement.</li>
+</ul>
+
+<h2 id="Spécification">Spécification</h2>
+
+<p>L'évènement 'onbeforeunload' a été introduit par Microsoft dans IE4 et s'est généralisé dans tous les navigateurs.</p>
+
+<p><a href="http://msdn.microsoft.com/en-us/library/ms536907%28VS.85%29.aspx">MSDN—onbeforeunload Event</a></p>