Jump to content

IFRAME HEIGHT IN CHROME


php_nub_qq

Recommended Posts

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   :o  :o  :suicide:

 

Please you're my last hope!

 

EDIT: NO jquery

Edited by php_nub_qq
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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 by php_nub_qq
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.