Any way to seamlessly integrate an iFrame?

Associate
Joined
21 Oct 2008
Posts
1,679
Location
Mooching... in your house
I have to use an iFrame on a site (I know I know) and I don't like the way it adds a vertical scrollbar... is there any way at all to neatly integrate the iFrame so that the page expands to accommodate it so that essentially, its not obvious that the iFrame is there?

Any chance?
 
Surely those methods hide part of the iFrame content?

As far as I can tell, jQuery auto-resize plugins would do the job, but the content I am pulling in is on a separate domain so this puts a spanned in the works...

Basically, I think I need something to resolve the height of the iFrame and stick it in a variable somewhere so I can refer to it and plonk it in my css... or something like that? maybe?
 
You looked at server-side? In PHP you could use cURL to grab the page, use DOMDocument() to strip the content you need and this allows you to format it accordingly. Saves having to bodge an iFrame.
that sounds like a monster job, the content i am pulling is pretty comprehensive... however another problem i've thought of is that the height of the iFrame changes based on the page changes that happen within the frame... this is going to be tricky isn't it...
 
ok maybe i should explain a bit more then if you say cURL is still the best way of doing things then ill look into it...

I am embedding an online shop, the people that run the shop supply customised pages set up just for me and handed to me via an iFrame, i pay a monthly fee and get the shop on my site and get to sell stuff... in this shop there are a good 100 pages, including baskets, checkouts etc etc so do you still think ripping the content is a neater solution than trying to tame the iFrame height? (serious question)
 
No not elegant at all, let me rephrase though, they have supplied a fully working shop which can be visited on its own but they then recommend that plonking it in an iFrame is the easiest way to implement it... however i suppose if anyone can think of a better way i'm certainly not confined to iFrames, I do however want to leave the site intact rather than ripping elements from it as like I said, there is a lot of stuff.

So maybe I should have explained that first, in terms of iFrames, javascript solutions have real troubles apparently when working with an external domain, for example this gives "access denied" errors:

Code:
<script language="JavaScript">
<!--
function calcHeight()
{
  //find the height of the internal page
  var the_height=
    document.getElementById('the_iframe').contentWindow.
      document.body.scrollHeight;

  //change the height of the iframe
  document.getElementById('the_iframe').height=
      the_height;
}
//-->

and edit this :

<iframe name="the_iframe" onLoad="calcHeight();" scrolling="no" width="730"  id="the_iframe" src="you_page.html" frameborder="0" allowtransparency="true"></iframe>

I have read that using <object> instead of <iframe> may be viable so I'll have to try and test that but I have a feeling it won't work cross-platform / cross-browser etc...

So I think I've given the whole picture now, open to any slick way to integrate their supplied pages ;)
 
Yes I've realised that cURL wont work due to links trying to work on my domain and even if i fiddled the links it still wouldn't work with the header from my site etc which needs to stay...

so in answer to your two recommendations, can't repoint the domain cuz its only on a certain page of my site, and secondly I need it (like i mentioned before) to maintain my header and footer for uniformity...

I think i'm still stuck with iFrames, but need to find a way to dynamically resize the iFrame based on the content which is the tricky bit due to security (cross-domain).
 
Staffy, that solution only works if the parent and the framed child are on the same domain as mentioned before, otherwise it kicks up access denied errors when trying to access DOM parameters...

Surely some parameter that is stored locally knows how large the frame is? I've spent a good few hours researching this and no answer has popped up yet... Am I chasing ghosts?
 
I see what I want to do isn't going to be feasible, the shop i'm pulling in wont offer custom branding and besides the iFrame content is only inner-content with no top navigation etc (it really was, for better or worse, designed to be used in an iFrame).

For now, I think I live with scrollbars ;)

Thanks to you all for your input :)
 
Back
Top Bottom