IFRAME Auto Resize in IE, FireFox by Javascript | ||
| ||
| <iframe id='ifrm'
frameborder=0 width=100% height=450 scrolling=no src='http://kurapa.com' ></iframe> <script language='javascript'> function getDocHeight(doc) { var docHt = 0, sh, oh; if (doc.height) { docHt = doc.height; } else if (doc.body) { if (doc.body.scrollHeight) docHt = sh = doc.body.scrollHeight; if (doc.body.offsetHeight) docHt = oh = doc.body.offsetHeight; if (sh && oh) docHt = Math.max(sh, oh); } return docHt; } function getReSize()
{ var iframeWin = window.frames['ifrm']; var iframeEl = window.document.getElementById? window.document.getElementById('ifrm'): document.all? document.all['ifrm']: null;
if ( iframeEl && iframeWin )
{ var docHt = getDocHeight(iframeWin.document); if (docHt != iframeEl.style.height) iframeEl.style.height = docHt + 'px';
} else { // firefox var docHt = window.document.getElementById('ifrm').contentDocument.height; window.document.getElementById('ifrm').style.height = docHt + 'px'; } } function getRetry() { getReSize(); setTimeout('getRetry()',500); } getRetry(); </script> | ||
| | ||
| |