IFrame Resize Javascript by Gavin Taylor - http://gavtaylor.co.uk - Dec 2007 ============================================================================= /** * Function for auto resizing Iframe to fit content. * Ensure that both the correct containing iframe is referenced as well as the body of loaded page. * @param String contentFrame is the frame to resize in the parent document * @param String bodyID is the id of the body that you wish to get the size of and pass to the iframe */ function resizeIframe(contentFrame,bodyID) { if(navigator.userAgent.indexOf("Firefox")!=-1) { // FF stuff goes here // if(self==parent) return false; // Checks that page is in iframe. else if(document.getElementById) // Sniffs for page var FramePageHeight = document.getElementById(bodyID).offsetHeight + 20; // add int to compensate for scrollbars parent.document.getElementById(contentFrame).style.height=FramePageHeight; // set frame height } else if(navigator.userAgent.indexOf("Opera")!=-1) { //Opera stuff goes here if(self==parent) return false; else if(document.getElementById) // Sniffs for page var FramePageHeight = document.getElementById(bodyID).scrollHeight + 20; // add int to compensate for scrollbars parent.document.getElementById(contentFrame).style.height=FramePageHeight; // set frame height } else { //IE stuff goes here if(self==parent) return false; // Checks that page is in iframe. else if(document.getElementById) // Sniffs for page var FramePageHeight = document.getElementById(bodyID).scrollHeight + 20; // add int to compensate for scrollbars parent.document.getElementById(contentFrame).style.height=FramePageHeight;// set frame height } }