JS to get page height onLoad or resize

I’ve encountered the issue of making a left menu the fixed height of the window and have vertical scrolling when the page is not tall enough to display the navigation elements (this currently happens in all available admin templates on the marketplace). So I built my own admin template and solved that issue with the following code using the toolbox plugin on a page load workflow:

function resize() {
    var h = window.innerHeight;
    var navHeight = h + 'px';
    $('#left-nav').css({'height':navHeight, 'overflow-y':'auto'});
}

resize();

$(window).resize(function() {
    resize();
});

I hope that is of use to you Scott or maybe others with this issue.

5 Likes