Skip to content

Instantly share code, notes, and snippets.

@yvesvanbroekhoven
Created December 1, 2010 10:00
Show Gist options
  • Save yvesvanbroekhoven/723271 to your computer and use it in GitHub Desktop.
Save yvesvanbroekhoven/723271 to your computer and use it in GitHub Desktop.
Set window min / max height on resize
(function(){
window.setWindowMinMaxDimensions = function(){
var min_height = 680;
var max_height = '100%';
var min_width = 950;
var max_width = 'auto';
window.onresize = function() {
var height = document.documentElement.clientHeight;
if (height < min_height) {
document.body.style.height = min_height + 'px';
} else {
document.body.style.height = max_height;
}
var width = document.documentElement.clientWidth;
if (width < min_width) {
document.body.style.width = min_width + 'px';
} else {
document.body.style.width = max_width;
}
};
};
setWindowMinMaxDimensions();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment