blob: 8be64c2109b463ae8b22108350ce4ccff9c49bed (
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
|
---
title: Document.width
slug: Web/API/Document/width
translation_of: Web/API/Document/width
---
<div>{{APIRef("DOM")}} {{Obsolete_header}}</div>
<div class="note">
<p><strong>Note :</strong> À partir de {{Gecko("6.0")}},<code> document.width </code>n'est plus pris en charge. Au lieu de cela, utilisez document.body.clientWidth. Voir {{domxref("element.clientWidth")}}.</p>
</div>
<p>Renvoie la largeur de l'élément {{HTMLElement("body")}} du document courrent en pixels.</p>
<p>Non pris en charge par Internet Explorer.</p>
<h2 id="Syntax">Syntaxe</h2>
<pre class="syntaxbox"><em>pixels</em> = document.width;
</pre>
<h2 id="Example">Exemple</h2>
<pre class="brush:js">function init() {
alert("La largeur du document est " + document.width + " pixels.");
}
</pre>
<h2 id="Alternatives">Alternatives</h2>
<pre class="syntaxbox">document.body.clientWidth /* largeur de <body> */
document.documentElement.clientWidth /* largeur de <html> */
window.innerWidth /* largeur de la fenêtre */
</pre>
<h2 id="Specification">Spécification</h2>
<p>HTML5</p>
<h2 id="See_also">Voir également</h2>
<ul>
<li>{{domxref("document.height")}}</li>
<li>{{domxref("Element.clientWidth")}}</li>
<li>{{domxref("Element.scrollWidth")}}</li>
</ul>
|