Compare Revisions

Window.getComputedStyle()

Revision 53585:

Revision 53585 by Brettz9 on

Revision 53586:

Revision 53586 by Tetrix on

Title:
window.getComputedStyle
window.getComputedStyle
Slug:
DOM/window.getComputedStyle
DOM/window.getComputedStyle
Tags:
DOM, Gecko, "Gecko DOM Reference", Fixit
DOM, Gecko, "Gecko DOM Reference", Fixit
Content:

Revision 53585
Revision 53586
t38var <i>style</i> = document.defaultView.getComputedStyle(<i>elemet38var <em>style</em> = document.defaultView.getComputedStyle(<em>el
>nt</i>, <i>pseudoElt</i>);>ement</em>, <em>pseudoElt</em>);
39</pre>
40    <pre class="eval">
41//practical example:
42&lt;html&gt;
43&lt;head&gt;
44&lt;style&gt;
45#elem_container{
46  position: absolute;
47  left: 100Px;
48  top: 200px;
49  height:100px ;
50}
51&lt;/style&gt;
52&lt;/head&gt;
53&lt;body&gt;
54&lt;div id="elem_container"&gt;dummy&lt;/div&gt;
55&lt;div id="output"&gt;&lt;/div&gt;  &lt;!--100px--&gt;
56&lt;script&gt;
57function getTheStyle(){
58var elem=document.getElementById("elem_container");
59var theCSSprop=document.defaultView.getComputedStyle(elem,null).g
 >etPropertyValue("height");
60document.getElementById("output").innerHTML=theCSSprop;
61}
62getTheStyle()
63&lt;/script&gt;
64&lt;/body&gt;
65&lt;/html&gt;
66 
67 

Back to History