0

why does it return 671 when i first time load the page with google chrome but it returns different value when i relad the page

$("#online").css({height: $(window).height()-40-$("#head").height()});
Mehman Manafov
  • 449
  • 1
  • 4
  • 8

2 Answers2

3

Try setting up the layout on load and resize

$(window).on("load resize", function (e) {
    $("#online").css({height: $(window).height()-40-$("#head").height()});
});
Robert Byrne
  • 562
  • 2
  • 13
  • 1
    [this question](http://stackoverflow.com/questions/3698200/window-onload-vs-document-ready) goes into detail, in this case its a shorthand way of binding both window events at once – Robert Byrne Sep 08 '13 at 14:35
0

Fiddle

$("#online").css({ height: $(window).height() - 40 - $("#head").height() +'px' }); 
Milan and Friends
  • 5,560
  • 1
  • 20
  • 28