Created
April 12, 2013 21:02
-
-
Save chrisvogt/5375110 to your computer and use it in GitHub Desktop.
Adjust scheduling iframe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function autoSizeIframeHeight(iframe, header, minHeight) { | |
| minHeight = minHeight || 300; | |
| function getViewportHeight() { | |
| var h = document.documentElement.clientHeight; | |
| return document.compatMode === "CSS1Compat" && h || document.body.clientHeight || h; | |
| } | |
| function getHeaderHeight() { | |
| return parseFloat(getComputedStyle(header,'height')); | |
| } | |
| function getComputedStyle(el, cssprop){ | |
| if (el.currentStyle) { // IE | |
| return el.currentStyle[cssprop]; | |
| } | |
| else if (document.defaultView && document.defaultView.getComputedStyle) { | |
| return document.defaultView.getComputedStyle(el, "")[cssprop]; | |
| } | |
| else { | |
| return el.style[cssprop]; | |
| } | |
| } | |
| function setIframeHeight() { | |
| var toHeight = getViewportHeight() - getHeaderHeight(); | |
| iframe.height = Math.max(toHeight, minHeight); | |
| body.style.overflowY = toHeight < minHeight ? 'auto' : 'hidden'; | |
| } | |
| var body = document.body || document.getElementsByTagName('body')[0]; | |
| setIframeHeight(); | |
| if (window.addEventListener) { | |
| window.addEventListener('resize', setIframeHeight, false); | |
| } | |
| else if (window.attachEvent) { | |
| window.attachEvent('onresize', setIframeHeight); | |
| } | |
| } | |
| autoSizeIframeHeight(document.getElementById('HaFrame'), document.getElementsByTagName('header')[0], 300); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment