I have a simple jQuery script that pushes the footer to the bottom of the page, even if the content is not long enough:
$(document).ready(function(){
positionFooter();
function positionFooter(){
var padding_top = $("#footer").css("padding-top").replace("px", "");
var page_height = $(document.body).height() - padding_top;
var window_height = $(window).height();
var difference = window_height - page_height;
if (difference < 0)
difference = 0;
$("#footer").css({
padding: difference + "px 0 0 0"
})
}
$(window).resize(positionFooter)
});
Unfortunately, the (document) .ready trigger is early and the dose does not take into account the loading of images and fonts, so the calculated value is incorrect. Is there a trigger suitable for such tasks?
Also the site I'm building uses Disqus fot comments, which also change the page length, although I think I need a reverse call to the Disqus script to take this change into account.
source
share