javascript window size breaks during startup
<p>I use the following code to get the window width and height </p>

<pre><code>function pageWidth() {
    return window.innerWidth != null ? window.innerWidth : document.documentElement &amp;&amp; document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null;
}
function pageHeight() {
    return window.innerHeight != null ? window.innerHeight : document.documentElement &amp;&amp; document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null ? document.body.clientHeight : null;
}
</code></pre>

<p>I call this javascript during the page load. If I keep my URL as home page and try to open the explorer, I see most of the times, these function give me values equal to 0.</p>

<p>Any idea how to fix it? My problem is, these functions work always but if I call these functions as part of IE home page, they return 0 ( 1 in 4 case).</p>

<p>is there any better way of getting width of a window?</p>
