6

Possible Duplicate:
Is there a way to have content from an IFRAME overflow onto the parent frame?

Here is my issue: I have two types of dialog which (should) look and act the same. One loads content directly into the page, and one uses a iframe to load content. I have an element which I need to overflow out of the iframe and show completely on the page. This element is basically an enhanced select element built with a list (ul/li). How can I make this act as a select would inside an iframe and overflow the iframe?

The first thing that comes to mind is to put the select/list outside of the iframe and position it in the correct spot, though this will require communicating between the iframe and parent more than I would like. Ideally I'd like a solution that keeps the select/list in the iframe.

Community
  • 1
  • 1
aepheus
  • 7,827
  • 7
  • 36
  • 51
  • 6
    Since an iframe is, basically, a web-page embedded in *another* page, I think this is impossible. It'd be like asking how to have element overflow the browser window...at least, I think so. I'd be interested to hear other peoples' take on the situation, though... – David Thomas May 02 '11 at 22:33
  • Immediate thought; not possible. – Jim Blackler May 02 '11 at 22:36

3 Answers3

14

You can't.

An <iframe> is an element containing a separate, distinct browser window (essentially).

Think of it literally like a window: when you look out of your window, the view of the outside stops at the windowframe.

This is in contrast to content inside, say, a scrollable <div>, which is more like a hand-held sheet of glass with some stuff painted on it and some other stuff stuck on with sellotape and hanging off over the edges.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
1

You could use php to load the page into your current page. A lot of people consider iframes bad practice. It would only take a couple lines of php to load the page elements, instead of an iframe, which is sometimes slower.

Here is how you would do it....

<?php
    include('file.html');
?>

You would put this line in a and contain it on the page just as you would with the iframe. You can use ajax/js to seamlessly change the content of the html and even load things from a server if you wish.

Trevor Arjeski
  • 2,108
  • 1
  • 24
  • 40
  • By php I take it you mean ajax. Iframes offer one main benefit, isolation. When you are running a single load page, this is a very important benefit. – aepheus May 02 '11 at 22:42
  • Then by that same isolation principle, how would an isolated iframe interact visually with its parent? It's not possible with an iframe. – Blender May 02 '11 at 22:43
  • 1
    @aepheus No. By php, he means [php](http://php.net). – McKayla May 02 '11 at 22:44
  • @aepheus Well, yes, you use ajax along with php to create asynchronous loading. It's the more modern way to 'isolate' a piece of a webpage. – Trevor Arjeski May 02 '11 at 22:45
  • This does not isolate anything, you're still throwing a lot of "junk" into the same page, bloating the dom, and if not handled well leaking memory. One would have to be especially careful with attaching/detaching and all that sort of stuff. – aepheus May 02 '11 at 22:49
  • @Trevor You need your `` tags. – McKayla May 02 '11 at 22:50
  • 1
    @aepheus why would it be junk? you can easily say that the stuff in the iframe is junk as well. I dont see your reasoning – Trevor Arjeski May 02 '11 at 22:56
  • I call it junk because I don't care to describe the contents of the iframe, regardless of what is there (in my case it is my own content I want to isolate due to heavy dom load) it puts extra strain on the page if you dump it there. Whereas an iframe is independent and isolated from the page. – aepheus May 02 '11 at 23:07
  • @aepheus I understand your preference, and I respect it. One final thing: With ajax you can minimize your DOM load, whereas with the iframe you're going to have to reload all that heavy "junk" every time the page is refreshed. Do as you please, though. – Trevor Arjeski May 02 '11 at 23:16
-2

Imagine that the document is a picture.

Imagine that the iFrame is a real frame.

Could you make the picture come out of the frame? No.

It's exactly the same thing here.

Your best bet is to figure out a way to avoid the iFrame.

Besides, iFrames are bad practice.

McKayla
  • 6,879
  • 5
  • 36
  • 48
  • 6
    This is not a reason why `iframes` are bad practice, though they generally are considered to be bad practice. Also, hurray for succumbing to the 21st century marketing propaganda that says that anything beginning "i" has to have the following letter capitalised... :P – Lightness Races in Orbit May 02 '11 at 22:43
  • @Tomalak iDon't get what you mean. ;) – McKayla May 02 '11 at 22:45