Computing.Net > Forums > Web Development > Remove frame from within

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Remove frame from within

Reply to Message Icon

Name: darkhalf
Date: May 24, 2006 at 12:37:38 Pacific
OS: xp
CPU/Ram: something
Product: or other
Comment:

Hi,

I'm trying to remove the frame from within the frame itself. Say my main page has an iframe (id main). Now from within the main frame, on a button click I want to be able to removeChild of the iframe... So close that window, but now the whole page itself... How can I reference the window?

Thank you



Sponsored Link
Ads by Google

Response Number 1
Name: Michael J (by mjdamato)
Date: May 24, 2006 at 14:27:01 Pacific
Reply:

OK, I *think* I understand your question. Using a "main" page with a "main" Iframe kind of confused the issue.

Anyway, the way that I understand it, you want to have a link within an Iframe which will load that Iframe into the parent window, correct?

You can do that like this (where iframe.htm is the HTML file for the Iframe content.) Replaced <> with [] for posting purposes:

[a href="#" onclick="parent.location='iframe.htm';"]Link[/a]


Michael J


0

Response Number 2
Name: darkhalf
Date: May 24, 2006 at 17:37:43 Pacific
Reply:

No, I don't want to change the contents of the 'main' iframe, but rather remove it as though it were no longer there.... for example

document.body.removeChild(document.getElementById('main'))... Something like that.. but I can't get the hierarchy to be able to reference the main frame...

To re-iterate, I have an .hta which I have created an iframe (id main), now inside the iframe there is another page that I want to be able to collapse (remove) the iframe from the .hta doc by using the removeChild option...


0

Response Number 3
Name: Michael J (by mjdamato)
Date: May 24, 2006 at 18:50:58 Pacific
Reply:

Ok, let me rephrase what I think you mean now. You want a link within the iframe that, when clicked, will remove the iframe from the parent document. If this is not what you mean, please link to an example or revise your explanation.

Ok, to do this you need to first enclose the iframe tags within div tags (hint: this makes the iframe a child). You could then remove the iframe directly within the iframe itself with a link like this:

[a href="#" onclick="parent.document.getElementById('divID').removeChild(this);"]Link[/a]

Or, my preference would be to create a function in the parent page and call that function from within the iframe. And, it would also be my preference to set the display property of the containing div to hidden (instead of removing the iframe) so that you could bring it back with another function.

Michael J


0

Response Number 4
Name: darkhalf
Date: May 24, 2006 at 19:07:09 Pacific
Reply:

Is there no way to do it without enclosing it within a div?


0

Response Number 5
Name: Michael J (by mjdamato)
Date: May 25, 2006 at 01:31:54 Pacific
Reply:

What's wrong with a div (or a span for that matter)?

[a href="#" onclick="parent.document.getElementById('main').style.display='none';"]Link[/a]

Doesn't remove it, per say, but it does hide it.

Michael J


0

Related Posts

See More



Response Number 6
Name: darkhalf
Date: May 25, 2006 at 07:39:58 Pacific
Reply:

had already tried that, but I keep getting an error saying that an object is required... It's as if it can't see the frame...


0

Response Number 7
Name: Michael J (by mjdamato)
Date: May 26, 2006 at 08:04:09 Pacific
Reply:

Well, I actually tested it before I posted it, so I know it works. Can you provide a link tot he pages or supply the code for your iframe in the parent page and the code for the link used in the iframe page?

Michael J


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Web Development Forum Home


Sponsored links

Ads by Google


Results for: Remove frame from within

Javascript & Frames www.computing.net/answers/webdevel/javascript-amp-frames/2055.html

Removing Folders From FTP www.computing.net/answers/webdevel/removing-folders-from-ftp/379.html

how to remove selected items from a list box www.computing.net/answers/webdevel/how-to-remove-selected-items-from-a-list-box-/4066.html