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 5 of 5
  1. #1
    Registered User
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to get a page to load within a frame that already exists?

    I see how to get a link to open within frames when the link is on an existing page, doing this works well - (main is the frame called from the index page to display the information)
    <a href="javascript:parent.main.location='http://stuff/mypage.html'">Your question here?</a>

    The question is - if my customer has an existing link or shortcut on the desktop to the page http://stuff/mypage.html then what within the structure of the page would force it to open with the framework? I believe that it would run a check as shown below

    //if not in frames
    if (parent.frames.length==0)
    //CHANGE "index.htm" to the URL of your main frame page
    window.location.replace("index.htm")

    It appears to me that I would then need to call a function and then run it in the body tag (onload type of call). Any help is appreciated.

  • #2
    New Coder
    Join Date
    Jul 2002
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    In order to get a page to load its parent frameset you could use something basic like this:

    <script>
    if (document.location == top.document.location)
    document.location = "frameset.htm"
    </script>


    This will load the frameset with the default page (stated in the frameset) into the "main" frame.


    If the page you want loaded into the main frame is not the default page then you require something a little more elaborate.

    I use on my site a script that makes sure that if a page is loaded out of a frame it loads its parent frameset with itself in the main frame

    Take a look at:

    http://www.huntingground.freeserve.c...es/loader2.htm

    When the page above loads it will load its parent frameset with itself in the main frame even though the default page normally loaded by the frameset is different.

    Let me know if you need further help with the script.
    You can contact me through the website.

  • #3
    Registered User
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm currently using this as the frame code within which I would like th epage to open up within the 'main' frame.

    <frameset rows="20%,*" border="0" frameborder="0">
    <frame name="header" src="header.htm" marginwidth="5" marginheight="5" scrolling="no" frameborder="1">
    <frameset cols="25.5%,*" border="1">
    <frame name="navigation" src="navigation.htm" marginwidth="5" marginheight="5" scrolling="auto" frameborder="0">
    <frame name="main" src="main.htm" marginwidth="5" marginheight="5" scrolling="auto" frameborder="0">
    </frameset>
    </frameset>

    The solution you gave me works like the one I had posted earlier - when I go to the individual page URL it forces me back to the index page with the frames - it doesn't force the window to open with the page URL in the main frame with the navigation and header frames where they belong.

    Currently looking at the code on the page you directed me to:
    <SCRIPT LANGUAGE="JavaScript">
    <!--
    if (top.location.href.indexOf("framfram.htm") == -1)
    top.location.href = "framfram.htm?loader2.htm&3";
    // -->
    </SCRIPT>
    I'll attempt to mod it to see if I can get the frames to load right...thanks for the help (and you don't have to stop if you know the proper order of making this happen...)!

  • #4
    New Coder
    Join Date
    Jul 2002
    Posts
    56
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have to apologise as it looks as though there is/was an error on my page.

    This error meant that the script would not work as it should.
    I have now corrected this.

    I attach a zip file containing the following which I created from the information you supplied regarding your frameset.

    Frameset.htm
    Header.htm
    Nav..htm
    Page 1.htm
    Page 2.htm
    Page 3.htm
    Link.htm

    If you open page2.htm or page3.htm directly they will load the frameset and themselves into the main frame.

    Links.htm contains links to pages 1 to 3.
    Page 1 one open as normal (not in frame)
    Pages 2 & 3 will load the frameset and themselves into the main frame.

    Hope I have got it right this time
    Attached Files Attached Files

  • #5
    Registered User
    Join Date
    Aug 2002
    Posts
    5
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks MrsG - the files work like a charm. I'll look at implementing this on the site.
    Last edited by bryandunn; 08-02-2002 at 08:53 PM.


  •  

    Posting Permissions

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