-CrAzY- Posted March 5, 2008 Posted March 5, 2008 Ok, So i have a iFrame, And i want it so when i click a link the page appears in the iframe but the iFrame automatically goes to the height of the page shown, Now!, This is easy in IE: <script type="text/javascript" language="javascript"> function getElement(id) { return document.getElementById? document.getElementById(id) : document.all? document.all(id) : null; } function getIFRAME_doc_height(oIframe) { return document.body && document.body.scrollHeight? oIframe.document.body.scrollHeight : oIframe.document.height? oIframe.document.height : null; } function IFRAME_size_to_content(iframe_id) { var oIframe = frames[iframe_id]; if (typeof oIframe!= 'undefined') { var wid = getElement(iframe_id).offsetWidth; var hgt = getIFRAME_doc_height(oIframe); if (wid && hgt) oIframe.resizeTo(wid,hgt); } } onload = function() { IFRAME_size_to_content('content'); } </script> <script type='text/javascript'> function elem(id) { return document.getElementById(id); } function iframeLoaded() { var idoc = elem('content').contentDocument; idoc.body.innerHTML = "awideriframethatshouldbeallononeline"; var more = " qwer poiu"; for (var i=10;i--;) idoc.body.innerHTML += more; alert(idoc.defaultView.location.href); // see [url]http://www.mozilla.org/docs/dom/dom...ndow_ref76.html[/url] idoc.defaultView.sizeToContent(); } </script> But when i came to testing my site, After being pleased that it looked great in IE, I tested it on FireFox, And that script wouldn't work, Has any one got the script to make it work in FF, Cheers ;) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.