diff options
| author | julieng <julien.gattelier@gmail.com> | 2021-10-02 17:20:24 +0200 |
|---|---|---|
| committer | SphinxKnight <SphinxKnight@users.noreply.github.com> | 2021-10-02 17:30:20 +0200 |
| commit | 1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde (patch) | |
| tree | 30a56efd3eff3a01bd1611e1840fdbbfacf544a4 /files/fr/web/api/clients/openwindow | |
| parent | c05efa8d7ae464235cf83d7c0956e42dc6974103 (diff) | |
| download | translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.gz translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.tar.bz2 translated-content-1407c8fdef01ecd0ffb8a8bd46e7113f119b9fde.zip | |
convert content to md
Diffstat (limited to 'files/fr/web/api/clients/openwindow')
| -rw-r--r-- | files/fr/web/api/clients/openwindow/index.md | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/files/fr/web/api/clients/openwindow/index.md b/files/fr/web/api/clients/openwindow/index.md index 1116da97f5..c991c6653c 100644 --- a/files/fr/web/api/clients/openwindow/index.md +++ b/files/fr/web/api/clients/openwindow/index.md @@ -3,37 +3,38 @@ title: Clients.openWindow() slug: Web/API/Clients/openWindow translation_of: Web/API/Clients/openWindow --- -<p>{{SeeCompatTable}}{{APIRef("Service Workers API")}}</p> +{{SeeCompatTable}}{{APIRef("Service Workers API")}} -<p>La méthode <strong><code>openWindow()</code></strong> de l'interface {{domxref("Clients")}} crée un nouveau niveau de contexte de navigation et charge une URL donnée. Si le script d'origine n'a pas la permission d'ouvrir une popup, <strong><code>openWindow()</code></strong> lèvera une InvalidAccessError.</p> +La méthode **`openWindow()`** de l'interface {{domxref("Clients")}} crée un nouveau niveau de contexte de navigation et charge une URL donnée. Si le script d'origine n'a pas la permission d'ouvrir une popup, **`openWindow()`** lèvera une InvalidAccessError. -<p>Dans Firefox, une méthode est authorisée d'ouvrir une popup seulement lorsqu'elle est appelée à la suite d'un click sur une notification.</p> +Dans Firefox, une méthode est authorisée d'ouvrir une popup seulement lorsqu'elle est appelée à la suite d'un click sur une notification. -<h2 id="Syntaxe">Syntaxe</h2> +## Syntaxe -<pre class="brush: js">ServiceWorkerClients.openWindow(url).then(function(WindowClient) { +```js +ServiceWorkerClients.openWindow(url).then(function(WindowClient) { // Faire quelque chose avec le WindowClient -});</pre> +}); +``` -<h3 id="Paramètres">Paramètres</h3> +### Paramètres -<dl> - <dt><code>url</code></dt> - <dd>Une {{domxref("USVString")}} représentant l'URL que le client veut ouvrir dans une nouvelle fenêtre. Généralement, cette valeur doit être une URL de la même origine que le script d'origine.</dd> -</dl> +- `url` + - : Une {{domxref("USVString")}} représentant l'URL que le client veut ouvrir dans une nouvelle fenêtre. Généralement, cette valeur doit être une URL de la même origine que le script d'origine. -<h3 id="Valeur_de_retour">Valeur de retour</h3> +### Valeur de retour -<p>Une {{jsxref("Promise")}} qui résoud un objet {{domxref("WindowClient")}} si l'URL est de la même origine que le service worker, et {{Glossary("null", "null value")}} sinon.</p> +Une {{jsxref("Promise")}} qui résoud un objet {{domxref("WindowClient")}} si l'URL est de la même origine que le service worker, et {{Glossary("null", "null value")}} sinon. -<h2 id="Exemples">Exemples</h2> +## Exemples -<pre class="brush: js">// Quand l'utilisateur click sur une notification, focus sur la fenêtre si elle existe, +```js +// Quand l'utilisateur click sur une notification, focus sur la fenêtre si elle existe, // ou ouvre en une autre. onotificationclick = function(event) { var found = false; clients.matchAll().then(function(clients) { - for (i = 0; i < clients.length; i++) { + for (i = 0; i < clients.length; i++) { if (clients[i].url === event.data.url) { // La fenêtre existe, focus dessus. found = true; @@ -49,25 +50,14 @@ onotificationclick = function(event) { } }); }; -</pre> +``` -<h2 id="Spécifications">Spécifications</h2> +## Spécifications -<table class="standard-table"> - <tbody> - <tr> - <th scope="col">Spécification</th> - <th scope="col">Statut</th> - <th scope="col">Commentaire</th> - </tr> - <tr> - <td>{{SpecName('Service Workers', '#clients', 'Clients')}}</td> - <td>{{Spec2('Service Workers')}}</td> - <td>Définition initiale</td> - </tr> - </tbody> -</table> +| Spécification | Statut | Commentaire | +| ------------------------------------------------------------------------ | ------------------------------------ | ------------------- | +| {{SpecName('Service Workers', '#clients', 'Clients')}} | {{Spec2('Service Workers')}} | Définition initiale | -<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2> +## Compatibilité des navigateurs -<p>{{Compat("api.Clients.openWindow")}}</p> +{{Compat("api.Clients.openWindow")}} |
