aboutsummaryrefslogtreecommitdiff
path: root/files/fr/web/api/htmlorforeignelement/focus/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/fr/web/api/htmlorforeignelement/focus/index.html')
-rw-r--r--files/fr/web/api/htmlorforeignelement/focus/index.html152
1 files changed, 0 insertions, 152 deletions
diff --git a/files/fr/web/api/htmlorforeignelement/focus/index.html b/files/fr/web/api/htmlorforeignelement/focus/index.html
deleted file mode 100644
index cdf177b278..0000000000
--- a/files/fr/web/api/htmlorforeignelement/focus/index.html
+++ /dev/null
@@ -1,152 +0,0 @@
----
-title: HTMLElement.focus()
-slug: Web/API/HTMLOrForeignElement/focus
-tags:
- - API
- - HTML DOM
- - HTMLElement
-translation_of: Web/API/HTMLOrForeignElement/focus
-original_slug: Web/API/HTMLElement/focus
----
-<div>{{ APIRef("HTML DOM") }}</div>
-
-<p>La méthode <strong><code>HTMLElement.focus()</code></strong> donne le focus à l'élément spécifié, s'il peut prendre le focus.</p>
-
-<h2 id="R.C3.A9sum.C3.A9" name="R.C3.A9sum.C3.A9">Syntaxe</h2>
-
-<pre class="syntaxbox">element.focus();
-element.focus(focusOption); // Paramètre objet</pre>
-
-<h3 id="Paramètres">Paramètres</h3>
-
-<dl>
- <dt><code>focusOptions</code> {{optional_inline}} {{experimental_inline}}</dt>
- <dd>Est un objet ayant les propriétés suivantes:</dd>
- <dd>
- <dl>
- <dt><code>preventScroll</code> {{optional_inline}}</dt>
- <dd>Est une valeur <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean" title="The Boolean object is an object wrapper for a boolean value."><code>Boolean</code></a>:
- <ul>
- <li>Si <code>false</code>, la méthode fera défiler la page pour que l'élément soit visible à l'écran.</li>
- <li>Si <code>true</code>,  la méthode ne fera PAS défiler la page pour que l'élément soit visible à l'écran.</li>
- </ul>
- </dd>
- </dl>
- </dd>
-</dl>
-
-<h2 id="Specification" name="Specification">Exemples</h2>
-
-<h3 id="Focus_on_a_text_field" name="Focus_on_a_text_field">Donner le focus à un champ texte</h3>
-
-<h4 id="JavaScript">JavaScript</h4>
-
-<pre class="brush: js line-numbers language-js"><code class="language-js">focusMethod <span class="operator token">=</span> <span class="keyword token">function</span> <span class="function token">getFocus</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"myTextField"</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">focus</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span></code></pre>
-
-<h4 id="HTML">HTML</h4>
-
-<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>input</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>text<span class="punctuation token">"</span></span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>myTextField<span class="punctuation token">"</span></span> <span class="attr-name token">value</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"Champ texte</span>.<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>p</span><span class="punctuation token">&gt;</span></span><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>p</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">onclick</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>focusMethod()<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Cliquez-moi pour donner le focus au champ texte!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span></code></pre>
-
-<h4 id="Résultat">Résultat</h4>
-
-<p>{{ EmbedLiveSample('Focus_on_a_text_field') }}</p>
-
-<h3 id="Focus_on_a_button" name="Focus_on_a_button">Donner le focus à un bouton</h3>
-
-<h4 id="JavaScript_2">JavaScript</h4>
-
-<pre class="brush: js line-numbers language-js"><code class="language-js">focusMethod <span class="operator token">=</span> <span class="keyword token">function</span> <span class="function token">getFocus</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"myButton"</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">focus</span><span class="punctuation token">(</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span></code></pre>
-
-<h4 id="HTML_2">HTML</h4>
-
-<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>myButton<span class="punctuation token">"</span></span><span class="punctuation token">&gt;Cliquez</span></span>!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>p</span><span class="punctuation token">&gt;</span></span><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>p</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">onclick</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>focusMethod()<span class="punctuation token">"</span></span><span class="punctuation token">&gt;Cliquez-moi pour donner le focus au bouton</span></span>!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span></code></pre>
-
-<h4 id="Résultat_2">Résultat</h4>
-
-<p>{{ EmbedLiveSample('Focus_on_a_button') }}</p>
-
-<h3 id="Focus_prevent_scroll" name="Focus_prevent_scroll">Focus avec option</h3>
-
-<h4 id="JavaScript_3">JavaScript</h4>
-
-<pre class="brush: js line-numbers language-js"><code class="language-js">focusScrollMethod <span class="operator token">=</span> <span class="keyword token">function</span> <span class="function token">getFocus</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"myButton"</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">focus</span><span class="punctuation token">(</span><span class="punctuation token">{</span>preventScroll<span class="punctuation token">:</span><span class="keyword token">false</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span>
-focusNoScrollMethod <span class="operator token">=</span> <span class="keyword token">function</span> <span class="function token">getFocusWithoutScrolling</span><span class="punctuation token">(</span><span class="punctuation token">)</span> <span class="punctuation token">{</span>
- document<span class="punctuation token">.</span><span class="function token">getElementById</span><span class="punctuation token">(</span><span class="string token">"myButton"</span><span class="punctuation token">)</span><span class="punctuation token">.</span><span class="function token">focus</span><span class="punctuation token">(</span><span class="punctuation token">{</span>preventScroll<span class="punctuation token">:</span><span class="keyword token">true</span><span class="punctuation token">}</span><span class="punctuation token">)</span><span class="punctuation token">;</span>
-<span class="punctuation token">}</span></code></pre>
-
-<h4 id="HTML_3">HTML</h4>
-
-<pre class="brush: html line-numbers language-html"><code class="language-html"><span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">onclick</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>focusScrollMethod()<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Cliquez-moi pour donner le focus au bouton!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">onclick</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>focusNoScrollMethod()<span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>Cliquez-moi pour donner le focus au bouton sans défilement!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span>
-
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>div</span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>container<span class="punctuation token">"</span></span><span class="language-css style-attr token"><span class="attr-name token"> <span class="attr-name token">style</span></span><span class="punctuation token">="</span><span class="attr-value token"><span class="property token">height</span><span class="punctuation token">:</span> <span class="number token">1000</span>px<span class="punctuation token">;</span> <span class="property token">width</span><span class="punctuation token">:</span> <span class="number token">1000</span>px<span class="punctuation token">;</span></span><span class="punctuation token">"</span></span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;</span>button</span> <span class="attr-name token">type</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>button<span class="punctuation token">"</span></span> <span class="attr-name token">id</span><span class="attr-value token"><span class="punctuation token">=</span><span class="punctuation token">"</span>myButton<span class="punctuation token">"</span></span><span class="language-css style-attr token"><span class="attr-name token"> <span class="attr-name token">style</span></span><span class="punctuation token">="</span><span class="attr-value token"><span class="property token">margin-top</span><span class="punctuation token">:</span> <span class="number token">500</span>px<span class="punctuation token">;</span></span><span class="punctuation token">"</span></span><span class="punctuation token">&gt;Cliquez</span></span>!<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>button</span><span class="punctuation token">&gt;</span></span>
-<span class="tag token"><span class="tag token"><span class="punctuation token">&lt;/</span>div</span><span class="punctuation token">&gt;</span></span></code></pre>
-
-<h4 id="Résultat_3">Résultat</h4>
-
-<p>{{ EmbedLiveSample('Focus_prevent_scroll') }}</p>
-
-<h2 id="Specification" name="Specification">Spécification</h2>
-
-<table class="standard-table">
- <thead>
- <tr>
- <th scope="col">Specification</th>
- <th scope="col">Status</th>
- <th scope="col">Comment</th>
- </tr>
- </thead>
- <tbody>
- <tr>
- <td>{{SpecName('HTML WHATWG', 'editing.html#dom-focus', 'focus')}}</td>
- <td>{{Spec2('HTML WHATWG')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('HTML5.1', 'editing.html#focus()-0', 'focus')}}</td>
- <td>{{Spec2('HTML5.1')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('HTML5 W3C', 'editing.html#dom-focus', 'focus')}}</td>
- <td>{{Spec2('HTML5 W3C')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('DOM2 HTML', 'html.html#ID-32130014', 'focus')}}</td>
- <td>{{Spec2('DOM2 HTML')}}</td>
- <td></td>
- </tr>
- <tr>
- <td>{{SpecName('DOM1', 'level-one-html.html#method-focus', 'focus')}}</td>
- <td>{{Spec2('DOM1')}}</td>
- <td></td>
- </tr>
- </tbody>
-</table>
-
-<h2 id="Notes">Notes</h2>
-
-<p>Si vous appelez <code>HTMLElement.focus()</code> à partir d'un gestionnaire d'événement mousedown, vous devez appeler <code>event.preventDefault()</code> pour empêcher le focus de quitter l'<code>HTMLElement</code>.</p>
-
-<h2 id="Compatibilité_des_navigateurs">Compatibilité des navigateurs</h2>
-
-<p>{{Compat("api.HTMLElement.focus")}}</p>
-
-<h2 id="Voir_aussi">Voir aussi</h2>
-
-<ul>
- <li>La méthode DOM {{domxref("HTMLElement.blur()")}} pour retirer le focus.</li>
- <li>{{domxref('document.activeElement')}} pour savoir quel élément a actuellement le focus.</li>
-</ul>