Results 1 to 14 of 14

Thread: [RESOLVED] Javascript: finding parent frame

  1. #1

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Resolved [RESOLVED] Javascript: finding parent frame

    Helo!
    My home page has frames.
    I don't want pages to be opened without being in the main frame (other frames are links and footer).
    First, how to find whether the page is in a frame?
    Second, how to force INDEX.HTML to show it (without changing it to ASP)?
    I've had enough with sainity!
    What's the use of it anyway?

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Javascript: finding parent frame

    This is your problem:
    Quote Originally Posted by Lemon Lime
    My home page has frames.
    For everyone's sake (but mostly yours), ditch the frames. They are so 90's

    Besides, no-one will ever find you on a search engine if you have frames. And it makes life unbearable complicated, as you're already finding out.

  3. #3

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    GGGGGRRRRR....
    I started working on it with frames, so I guess I can't just get rid of them.
    As long as I'm the ONLY webmaster, it might be a bit impossible mission...
    Well, people are finding pages in my site, (even with GOOOOOOGLE!!!) but can't navigate out, to see other links.

    I found this http://adamv.com/dev/javascript/querystring.
    After figuring out I wrote this on my page:
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
       "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    <script src="querystring.js"></script>
    <head>
    <meta http-equiv="Content-Language" content="he">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
    <title>index.html</title>
    <base target="main">
    </head>
    
    <frameset  cols="*,165"  framespacing="0"  frameborder=0 >
        	<frameset rows="*,95"  frameborder=0>
    <frame name="main" scrolling="auto" noresize frameborder=0 target="main" src="main.htm">
    <frame  name=footer src=footer.htm frameborder=0 >
    </frameset >
      <frame name="links" src="links.htm" scrolling="auto" frameborder=0 target="main"></frameset>
    
    <script type='text/javascript'>
    var qs = new Querystring();
    var file1 = qs.get('redir','main.htm');
    document.getElementById("main").src = file1
    </script>
    </html>
    When writing
    Code:
    index.html?redir=123.html
    I get nothing!
    What da?!
    I've had enough with sainity!
    What's the use of it anyway?

  4. #4
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: finding parent frame

    To detect if you're in frames or not,

    if(top.location.href == self.location.href)

    This means that you are NOT in frames. If this evaluates to true, set top.location.href to your frame page.

    I don't understand what you want in your second post though, can you explain?

  5. #5

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    10X!
    I want to redirect all files to "/index.html" BUT to still be in the same page.
    i.e: if i open http://.....gallery.html so it will open index.html, and gallery.html will be showen in the "main" frame.
    I've had enough with sainity!
    What's the use of it anyway?

  6. #6
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: finding parent frame

    Use

    top.frames['mainframe'].document.location.href = file1

    Instead of

    document.getElementById("main").src = file1

  7. #7

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    It does'nt work.
    this is my new file:

    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
       "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    
    <head>
    <meta http-equiv="Content-Language" content="he">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1255">
    <title>INDEX</title><base target="main">
    <script src="querystring.js" type="text/javascript"></script>
    <script type='text/javascript'>
    function reframe() {
    var qs = new Querystring();
    var file = qs.get('redir','main.htm');
    top.frames['main'].document.location.href = file;}
    </script>
    </head>
    <frameset rows="*,95">
    <frame name='main' id='main' scrolling="auto" noresize frameborder=0 src="main.htm">
    <frame  name=footer src=footer.htm frameborder=0 >
    </frameset>
    </html>
    and still...
    I've had enough with sainity!
    What's the use of it anyway?

  8. #8
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: finding parent frame

    after getting the file variable, try alert(file);

    What do you get?

  9. #9

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    Nothing!
    I've had enough with sainity!
    What's the use of it anyway?

  10. #10

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    Code:
    window.onload=reframe;
    and it's done!
    now, about the first one....

    Code:
    if(top.location.href == self.location.href){
    document.redirect("index.html?redir=" +document.href);}
    is wrong...
    I've had enough with sainity!
    What's the use of it anyway?

  11. #11
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: finding parent frame

    if(top.location.href == self.location.href){
    top.location.href = "index.html?redir=" + document.href);}

  12. #12

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: Javascript: finding parent frame

    10X!!!!!!!

    Code:
    if(top.location.href == self.location.href){
    top.location.href = "index.html?redir=" +top.location.href;
    document.refresh}
    I've had enough with sainity!
    What's the use of it anyway?

  13. #13
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170

    Re: Javascript: finding parent frame

    You're welcome, add 'Resolved' to the thread title now.

  14. #14

    Thread Starter
    Addicted Member Lemon Lime's Avatar
    Join Date
    Jul 2000
    Location
    Space, the final frontier, go along the yellow brick road,turn left then left again. In the service window, ask for the insane dude.
    Posts
    167

    Re: [RESOLVED] Javascript: finding parent frame

    I know I can be a real pain in the A$$ but it's not so good..
    Is it possible not to show the full URI (of the second page) on the address?
    It's like this :
    file:///D:/container/index.html?redir=file:///D:/container/copy%20of%20main.htm
    And it's
    Last edited by Lemon Lime; Mar 23rd, 2006 at 11:19 AM.
    I've had enough with sainity!
    What's the use of it anyway?

Posting Permissions

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



Click Here to Expand Forum to Full Width