You are here:

DHTML/Removing Frames

Advertisement


Question
QUESTION: Hi,

My web page has two frames a search navigation frame across the top and the results content frame below.

I wish to create a button in the navigation frame that will allow a user to get rid of a navigation frame, and opening up to the full screen the content frame.

How can this be done?

Thanks

Ben

ANSWER: Hi Ben, I'm assuming you have a basic understanding of JavaScript.  Just make sure to place the function below somewhere between a <script> tag within <head> or in an external js file.

The Function

function removeFrames() {
if (top.location != self.location) top.location = self.location;
}

The Link

Remove Frames

---------- FOLLOW-UP ----------

QUESTION: This is great but there is a slight snag. The button to remove the frame, needs to be in the frame i want removed, and if i use this function it removes the frame i want to keep. What do i need to modify?

Thanks

Answer
If you're removing one frame, leaving only one other frame, why wouldn't you want both frames gone?  If I were creating a webpage with only one frame, I would have no need for frames at all.  Maybe I'm confused at what you're asking.  Do you have anything online that I can look at?

Update:

Have you looked at this before?
http://www.irt.org/script/316.htm

I got that link from here:
http://www.irt.org/script/frame.htm

This is an excellent source for specific frame questions.  I think it's likely your answer lies somewhere in this data source.

Good luck, Ben.

DHTML

All Answers


Answers by Expert:


Ask Experts

Volunteer


Andrew Hoffman

Expertise

Ask me about JavaScript, CSS, HTML5/XHTML, or PHP. Chances are I'll be able to help you. I know the economy is in the tank, but if you like my answer, please consider donating a few bucks. It's like tipping your barista, if your barista served fresh code instead of coffee.

Experience

I started doing this when boy bands were still cool.

Education/Credentials
I read a lot of nerdy books to get here.

©2012 About.com, a part of The New York Times Company. All rights reserved.