Mehman Manafov
Mehman Manafov

Reputation: 449

JQuery gives different values for window height each time i refresh the page

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()});

Upvotes: 0

Views: 907

Answers (2)

Robert Byrne
Robert Byrne

Reputation: 560

Try setting up the layout on load and resize

$(window).on("load resize", function (e) {
    $("#online").css({height: $(window).height()-40-$("#head").height()});
});

Upvotes: 3

Milan and Friends
Milan and Friends

Reputation: 5610

Fiddle

$("#online").css({ height: $(window).height() - 40 - $("#head").height() +'px' }); 

Upvotes: 0

Related Questions