Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.
var WindowHeight = jQuery(window).height();
var HeaderHeight = 0;
if ($(window).width() > 1024) {
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}
var windowsize = $(window).width();
jQuery(window).resize(function() {
windowsize = $(window).width();
if (windowsize > 1024) {
var WindowHeight = jQuery(window).height();
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}
});
var WindowHeight = jQuery(window).height();
var HeaderHeight = 0;
if (windowsize > 1024) {
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}
var windowsize = $(window).width();
jQuery(window).resize(function() {
windowsize = $(window).width();
if (windowsize > 1024) {
var WindowHeight = jQuery(window).height();
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}else{
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}
});
added a resize function to turn the full height function on and offBut there are no details to suggest what on and off are. Apparently you're happy with the on state.
var WindowHeight = jQuery(window).height();
var HeaderHeight = 0;
if (windowsize > 1024) {
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}
var windowsize = $(window).width();
jQuery(window).resize(function() {
windowsize = $(window).width();
if (windowsize > 1024) {
var WindowHeight = jQuery(window).height();
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}else{
jQuery(".fullheight").css("height", "");
}
});
function does not work until resize occurs..You actually have two separate functions running in your code. Lines 5-7 are executed when the page loads to determine if the initial window is larger that 1024 pixels wide. The issue is probably with where on the page this code has been inserted. If you have this code in the head section of the page, the target div with the class name .fullheight has not be added to the DOM yet, so it cannot be altered yet. If you have the code at the bottom of the body element, it should work as expected.
var WindowHeight = jQuery(window).height();
var HeaderHeight = 0;
var windowsize = $(window).width();
jQuery(window).resize(large_screen); // execute on window resize
jQuery(large_screen); // execute on page load
function large_screen() {
windowsize = $(window).width();
if (windowsize > 1024) {
var WindowHeight = jQuery(window).height();
jQuery(".fullheight").css("height", WindowHeight - HeaderHeight);
}else{
jQuery(".fullheight").css("height", "");
}
};
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Open in new window
But there is nothing in your resize code that would undo this when the screen width is less than 1024 after the resize.The condition would be re-evaluated on each resize and the height will be adjusted when the window size is more than 1024, but nothing will be done when the window size is less than 1024. The previous adjustment will prevail.