Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 9 of 9
  1. #1
    vin
    vin is offline
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Closing side navigation frame

    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

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    top.location = "http://whatever"

    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)

  • #3
    vin
    vin is offline
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #4
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Last edited by Algorithm; 01-10-2003 at 02:33 AM.

  • #5
    vin
    vin is offline
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #6
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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>

  • #7
    vin
    vin is offline
    New Coder
    Join Date
    Jan 2003
    Posts
    13
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #8
    Regular Coder
    Join Date
    Jul 2002
    Location
    USA
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #9
    Senior Coder
    Join Date
    Jun 2002
    Location
    41° 8' 52" N -95° 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What Algorithm said... I would (and do) open other sites in a new window, personally.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •