php_nub_qq Posted May 23, 2013 Share Posted May 23, 2013 (edited) Hello. I had my doubts where to post this but anyway I am going insane because I have been struggling with this for more than 4 HOURS !!! I want to extend an IFRAME so that its height matches its content's height. I've crawled the whole entire web and read every single possible solution so you're my last hope. All solutions don't work in CHROME Please you're my last hope! EDIT: NO jquery Edited May 23, 2013 by php_nub_qq Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/ Share on other sites More sharing options...
kicken Posted May 23, 2013 Share Posted May 23, 2013 If you want the iframe to adjust it's height to whatever page is loaded within it then you'll need Javascript of some sort, there is no pure HTML solution. jQuery would probably allow for the simplest solution. Also the content of the frame would probably have to pass the same-origin policy test. Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1431909 Share on other sites More sharing options...
php_nub_qq Posted May 23, 2013 Author Share Posted May 23, 2013 (edited) I know, but it is possibly a css/javascript/html issue and since html is in the center of all of that I thought I should post here. Anyway the problem is that these Iframes are OFFLINE. Users of my site have the option to download a full chat history to their computer and that consists of separate files for each day, if the user has not a strong enough machine to open them all at once, and a file which has all files ( whole history ) in it as IFRAMES because I know not of another way to include HTML into HTML without a server? And thus comes all my trouble of accessing child/parent frames I get a bunch of errors not allowing me to do anything... I'm starting to lose hope Edited May 23, 2013 by php_nub_qq Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1431913 Share on other sites More sharing options...
xenLiam Posted May 24, 2013 Share Posted May 24, 2013 You said no jQuery. Here's one in pure JS. function iframe_height() { var iHeight=document.getElementById('your_iframe_id').contentWindow.document.body.scrollHeight; document.getElementById('your_iframe_id').height=iHeight; } You can call it through: <iframe src="yourpage.html" id="your_iframe_id" onload="iframe_height()"></iframe> I haven't tested this one out yet, but in theory it should work. Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1432000 Share on other sites More sharing options...
php_nub_qq Posted May 24, 2013 Author Share Posted May 24, 2013 You said no jQuery. Here's one in pure JS. function iframe_height() { var iHeight=document.getElementById('your_iframe_id').contentWindow.document.body.scrollHeight; document.getElementById('your_iframe_id').height=iHeight; } You can call it through: <iframe src="yourpage.html" id="your_iframe_id" onload="iframe_height()"></iframe> I haven't tested this one out yet, but in theory it should work. I cannot access contentWindow of child, I get this Unsafe JavaScript attempt to access frame with URL file:///C:/blabla/chatHistory/history/08-05-2013.html from frame with URL file:///C:/blabla/chatHistory/index.html. Domains, protocols and ports must match. Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1432026 Share on other sites More sharing options...
xenLiam Posted May 24, 2013 Share Posted May 24, 2013 Mhm, well then I guess I'm all out of options unless you use jQuery. Sorry. Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1432029 Share on other sites More sharing options...
php_nub_qq Posted May 24, 2013 Author Share Posted May 24, 2013 I gave up and tried jquery as well, it didn't work. SOP is causing the same errors Quote Link to comment https://forums.phpfreaks.com/topic/278325-iframe-height-in-chrome/#findComment-1432033 Share on other sites More sharing options...
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.