...

View Full Version : Closing side navigation frame



vin
01-10-2003, 01:51 AM
I have a page consisting of two frames, a narrow one on the left hand side used for navigation, and the main frame on the right.

Is it is possible to set up a button on the navigation frame that when clicked, closes the navigation frame and makes the Main frame expand to take over the whole page?

Here's the page: http://comnet.web1000.com

Vin

whammy
01-10-2003, 02:19 AM
top.location = "http://whatever"

:)

vin
01-10-2003, 02:44 AM
Thanks for your prompt reply Whammy.

Could you please be a bit more specific though?

Where do I put this code? I tired a few different ways but was unable to get it working.

Could you please type out the whole line of code?

Vin

Algorithm
01-10-2003, 03:30 AM
Here's code that will work, but ONLY WITHIN YOUR OWN SITE.

top.location = top.main.location;

Javascript has built-in limitations to prevent you from accessing any data outside your own server, so if the page in your "main" frame is ever outside your site, the code above will throw an error.

vin
01-10-2003, 03:55 AM
Thanks for that.

Unfortunately, I am still a novice when it comes to Javascript, having previously only ever worked in HTML.

Where abouts in the page do I add this line of text to make it work with a hyperlink?

What do I add before and after the line of text that you have provided so that it becomes functional after clicking on the words "Close this Frame"?

As you can see from my page so far, when you click on the Hotmail llink it automatically opens outside of the frameset, while the other page (Daily Grail) loads up in the main frame.

I don't really need the sites to open outside of the frameset like Hotmail is doing here. Instead I would be just as happy if I could get the sites staying in the main frame but taking up the whole screen width. I just want to get rid of the side Navigational frame.

http://comnet.web1000.com

Vin

Algorithm
01-10-2003, 04:09 AM
To call this code from a link (while staying put):

<a href="javascript:top.location=top.main.location">Remove Frames</a>

To "break out" of frames while going elsewhere:

<a href="http://www.anothersite.com/" target="_top">Go somewhere else</a>

vin
01-10-2003, 05:40 AM
Thanks !

That works now.

Only problem now is as you described above: If I have another website inside my main page and try to close the navigation frame by clicking on the link generated by the your code, it gives an error.

So I then tried to fix that by specifically directing it to my Main Frame with this adapted code:

<a href=javascript:top.location="http://comnet.web1000.com/AkhetMain.htm">Close Navigation</a>

But this generates the same error.

So then I tried a variation of the other code you gave, like this:

<a href="http://comnet.web1000.com/AkhetMain.htm" target="_top">Close Nav</a>

But that doesn't work for the same reason. I thought that perhaps a Frame within that Frame might be the way around it.

What do you think?

Do you know how I can get around this problem?

Vin

Algorithm
01-10-2003, 07:07 AM
Originally posted by vin
I tried a variation of the other code you gave, like this:

<a href="http://comnet.web1000.com/AkhetMain.htm" target="_top">Close Nav</a>

But that doesn't work for the same reason.That code should work. If it isn't, then there's another reason for it.

But in general, if you're linking to other websites, you shouldn't load them inside your own frames. Apart from making Javascript methods difficult, it's also confusing for the user and offensive to the website owner. When you link to external sites, you should always target top.

whammy
01-11-2003, 12:46 AM
What Algorithm said... I would (and do) open other sites in a new window, personally.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum