Skip to content

Instantly share code, notes, and snippets.

@svandragt
Last active August 29, 2015 14:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svandragt/cbbd138d15f61fb71df9 to your computer and use it in GitHub Desktop.
Save svandragt/cbbd138d15f61fb71df9 to your computer and use it in GitHub Desktop.
function SvdSetElementFullHeight(elementId, bpad) {
// default
bpad = (typeof bpad === "undefined") ? 20 : bpad;
var inDesignMode = document.forms[MSOWebPartPageFormName].MSOLayout_InDesignMode.value;
if (inDesignMode == "1"){
return;
}
var e = document.getElementById(elementId);
if (!e) { return; }
// viewport height - how far down the page it is - 20 pixels bpad
e.style.height = (window.innerHeight - e.getBoundingClientRect().top - bpad) + "px";
// hide scrollbar because MS likes to put empty paragraphs into the template
var s4w = document.getElementById('s4-workspace');
if (s4w) { s4w.style.overflow = 'hidden'; }
}
function SvdSetFullHeight() {
SvdSetElementFullHeight('WebPartWPQ2');
}
// attach to load / resize
if (window.addEventListener) {
window.addEventListener('load', SvdSetFullHeight, false);
window.addEventListener('resize', SvdSetFullHeight, false);
} else {
window.attachEvent('onload', SvdSetFullHeight);
window.attachEvent('onresize', SvdSetFullHeight);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment