Referring to one frame from another frame

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sform
    New Member
    • Apr 2008
    • 4

    Referring to one frame from another frame

    I have a frameset with three frames:

    [HTML]<html>
    <head>
    <title>Untitled </title>
    </head>
    <frameset rows="10%,*,10% " frameborder="1" >
    <frame src="button.htm " name="button" />
    <frame src="main.htm" name="Main" id="Main" />
    <frame src="menu2.htm" name="menu-one" />
    </frameset>
    </html>[/HTML]

    My research says to refer from 1 frame to another like this:

    [HTML]<INPUT TYPE="button" VALUE="Titles Only" onClick="top.fr ames[0].location='main .htm' ">[/HTML]

    When I try this I get
    top.frames0 is not an object

    Any suggestions?
    Last edited by gits; Apr 19 '08, 07:56 AM. Reason: added code tags
  • pronerd
    Recognized Expert Contributor
    • Nov 2006
    • 392

    #2
    Ok. First of "top.frames[0].location='main .htm' " needs to be "top.frames[0].location.href='main.htm' "

    Secondly it is usually easier to access elements across frames with relative rather than explicit paths. So something like this would work better.
    Code:
    parent.frames[0].location.[B]href[/B]='main.htm' 
    parent.button.location.[B]href[/B]='main.htm'

    Comment

    • sform
      New Member
      • Apr 2008
      • 4

      #3
      Thanks for your reply - still working on this:

      Frameset page:

      [HTML]<html>
      <head>
      <title>Untitled </title>
      </head>
      <frameset rows="10%,*,10% " frameborder="1" >
      <frame src="buttons.ht m" name="buttons"/>
      <frame src="display.ht m" name="display"/>
      <frame src="links.htm" name="links"/>
      </frameset>
      </html>
      [/HTML]
      Buttons.htm:

      [HTML]<html>
      <head>
      <title>Button s</title>
      <script type="text/javascript">

      function openframes() {

      var a = top.location.hr ef="links.htm" ;
      }
      </script>

      </head>
      <body>
      <table>
      <tr><td>

      <input type=button value="Helper" onClick="openfr ames()"/>

      </td>
      </table>
      </body>
      </html>
      [/HTML]
      This puts links.htm into the full page, but what I want is for links.htm to appear in the "display" frame.
      Should be able to do this by somehow referring to the frames array (frames[0[, frames[1]).
      Last edited by acoder; Apr 22 '08, 01:49 PM. Reason: Added code tags

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        Try:
        [code=javascript]top.display.loc ation.href="lin ks.htm";[/code]

        PS. please use [code] tags when posting code. Thanks.

        Comment

        • sform
          New Member
          • Apr 2008
          • 4

          #5
          Originally posted by acoder
          Try:
          [code=javascript]top.display.loc ation.href="lin ks.htm";[/code]

          PS. please use [code] tags when posting code. Thanks.
          I get "top.display.lo cation is null or not an object"

          Comment

          • acoder
            Recognized Expert MVP
            • Nov 2006
            • 16032

            #6
            Are you sure you have it like this:[code=javascript]function openframes() {
            top.display.loc ation.href="lin ks.htm";
            }[/code]

            Comment

            • sform
              New Member
              • Apr 2008
              • 4

              #7
              Originally posted by acoder
              Are you sure you have it like this:[code=javascript]function openframes() {
              top.display.loc ation.href="lin ks.htm";
              }[/code]

              Just discovered that this happens only when previewing in the WYSIWYG HTML-Kit program but not when I preview in IE 6!

              Thanks for your help!

              Comment

              • acoder
                Recognized Expert MVP
                • Nov 2006
                • 16032

                #8
                No problem, glad it's working. Post back to the forum if you have any more questions.

                Comment

                Working...