I have a simple jQuery script which pushes the footer to the bottom of the page, even if the content is not long enough:
$(document).ready(function(){
positionFooter();
function positionFooter(){
//get the div's padding
var padding_top = $("#footer").css("padding-top").replace("px", "");
//get the current page height - the padding of the footer
var page_height = $(document.body).height() - padding_top;
var window_height = $(window).height();
//calculate the difference between page and window height
var difference = window_height - page_height;
if (difference < 0)
difference = 0;
//write the changes to the div
$("#footer").css({
padding: difference + "px 0 0 0"
})
}
//re-run the function if browser window is resized
$(window).resize(positionFooter)
});
Unfortunately the (document).ready trigger is to early and dose not consider image & font loading, so the value that is calculated is incorrect. Is there a trigger that is suited for this kind of tasks?
Also the site I'm building is using Disqus fot comments, which also changes the page length again, though I think I need a call-back from the Disqus script to take that change into consideration.