Why doesn't $(window).height(); return a value, but $(document).height(); does?
<p>I'm trying to use jQuery to get current window height. I intend to set a variable with this value, and update the value upon resize. For some reason, $(window).height(); always returns zero, but  $(document).height(); returns a value. Why would this be? </p>

<p>(code snipped for brevity)</p>

<pre><code>$(document).ready(function () {

function drawGrid() {

    var context = document.getElementById("gridCanvas").getContext("2d");

    var height = $(window).height();
    var width = height/2/8;
    alert(height);

    $(window).resize(function () {
        // do some stuff
    });

        // do some cool drawing stuff

    }

    drawGrid();

});
</code></pre>
