SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question change two frames?

    hello

    using this code to change two frames, have used it before and seems on my mac but tested it on, IE 6.0.2600, Windows XP and the javascript part does'nt seem to work?

    <a href="submenu.php" target="submenu" onclick="parent.frame['content'].location='content.php'; return true"><img src="button.gif" alt="collection" name="img1" width="89" height="18" border="0" /></a>

    any ideas would be appreciated as i'm stumped on how to do this differently!

    a+
    gar

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You could try moving the submenu link command into the javascript also...

    Code:
    <a href="#" onclick="parent.frame['submenu'].location='submenu.php';parent.frame['content'].location='content.php'">
    <img src="button.gif" alt="collection" name="img1" width="89" height="18" border="0" />
    </a>
    Of course, it would probably look cleaner if you wrapped it up in a function in the header and just called the function name on the link.

    Code:
    <script type="text/javascript">
    
    function goTwo(n2submenu,n2content) {
    parent.frame['submenu'].location=n2submenu;
    parent.frame['content'].location=n2content;
    }
    
    </script>
    
    ...
    
    <a href="#" onclick="goTwo('submenu.php','content.php')">Link</a>
    Just an idea
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  3. #3
    Sultan of Ping jofa's Avatar
    Join Date
    Mar 2002
    Location
    SvÝ■jˇ­
    Posts
    4,080
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't parent.frames['content'] the correct name of the frame?

  4. #4
    The doctor is in... silver trophy MarcusJT's Avatar
    Join Date
    Jan 2002
    Location
    London
    Posts
    3,509
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by jofa
    Isn't parent.frames['content'] the correct name of the frame?
    Indeed - "frames[]" is the name of the associative array, not "frame[]"...!
    MarcusJT
    - former ASP web developer / former SPF "ASP Guru"
    - *very* old blog with some useful ASP code

    - Please think, Google, and search these forums before posting!

  5. #5
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My bad. I knew that, honest. That's what happens when I post way past my bedtime.

    A quick point, it's better to use...

    parent.frame['submenu'].location.href=...

    ...as that way the href change will be logged in the history and can therefore be navigated using the back and forward buttons.


    Also, in case you are wanting to use this with iframes (as opposed to standard frames) it is worth noting that support for this particular method is not universal.
    There are ways round it of course. It's just a matter of using alternative methods.

    Have I redeemed myself yet?
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  6. #6
    SitePoint Addict Garrett's Avatar
    Join Date
    Feb 2001
    Location
    England
    Posts
    352
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    my error guys, fixed the problem the "frames" was it and seems to work fine now.

    thanks

    a+
    gar


Bookmarks

Posting Permissions

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