aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/eventsource/onopen/index.html
blob: 64b0d58fb9486f383f82a108a169dbbf53a2e409 (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
---
title: EventSource.onopen
slug: Web/API/EventSource/onopen
tags:
  - API
  - Event Handler
  - EventSource
  - Propriété
  - Reference
translation_of: Web/API/EventSource/onopen
---
<div>{{APIRef('Server Sent Events')}}</div>

<p>La propriété <code><strong>onopen</strong></code> de l'interface {{domxref("EventSource")}} est un {{event("Event_handlers", "event handler")}} qui est appelé lorsqu'un est évènement {{event("open")}} est reçu, indiquant que la connexion vient d'être établie.</p>

<h2 id="Syntaxe">Syntaxe</h2>

<pre class="syntaxbox">eventSource.onopen = function</pre>

<h2 id="Exemples">Exemples</h2>

<pre class="brush: js">evtSource.onopen = function() {
  console.log("Connexion au serveur établie.");
};</pre>

<div class="note">
<p><strong>Note :</strong> Vous pouvez trouver un exemple complet sur GitHub — voir <a href="https://github.com/mdn/dom-examples/tree/master/server-sent-events">Simple SSE demo using PHP.</a></p>
</div>

<h2 id="Spécifications">Spécifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spécification</th>
   <th scope="col">Statut</th>
   <th scope="col">Commentaires</th>
  </tr>
  <tr>
   <td>{{SpecName('HTML WHATWG', "comms.html#handler-eventsource-onopen", "onopen")}}</td>
   <td>{{Spec2('HTML WHATWG')}}</td>
   <td>Définition initiale.</td>
  </tr>
 </tbody>
</table>

<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>

<p>{{Compat("api.EventSource.onopen")}}</p>

<h2 id="Voir_aussi">Voir aussi</h2>

<ul>
 <li>{{domxref("EventSource")}}</li>
</ul>