How do I get <TITLE> from frame?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • D. Alvarado

    How do I get <TITLE> from frame?

    Hello,
    I am trying to find the <TITLE> element of my document. Normally

    alert(document. title);

    works just fine, but when this statement is within a page that is a
    frame in a larger document, the above call always returns the title of
    the parent (container) page. Is it possible through JS to deduce the
    <TITLE> element of the current page, even if that page is a frame?

    Much thanks - Dave
  • Mick White

    #2
    Re: How do I get &lt;TITLE&gt ; from frame?

    D. Alvarado wrote:[color=blue]
    > Hello,
    > I am trying to find the <TITLE> element of my document. Normally
    >
    > alert(document. title);
    >
    > works just fine, but when this statement is within a page that is a
    > frame in a larger document, the above call always returns the title of
    > the parent (container) page. Is it possible through JS to deduce the
    > <TITLE> element of the current page, even if that page is a frame?
    >
    > Much thanks - Dave[/color]

    alert(top.docum ent.title);

    Mick

    Comment

    • D. Alvarado

      #3
      Re: How do I get &lt;TITLE&gt ; from frame?

      Thanks for the reply, but I think I misphrased my question. If my
      "top" document is:

      <html>
      <head><title>To p</title></head>
      <body>
      <table>
      <tr><td><ifra me width="200" height="300" src="frame.htm"
      name="n"></iframe></td></tr>
      </table>
      </body>
      </html>

      and my frame, "frame.htm" is:

      <html>
      <head><title>Fr ame</title></head>
      <body>
      <script type="text/javascript">
      alert(document. title);
      </script>
      </body>
      </html>

      I want the alert to say "Frame" not "Top," which is what displays with
      the current text or even if I include the suggestion
      "alert(top.docu ment.title)". Again, much thanks if someone can crack
      this enigmatic problem. -

      Mick White <mwhite13@BOGUS rochester.rr.co m> wrote in message news:<sh7_b.429 34$um1.29695@tw ister.nyroc.rr. com>...[color=blue]
      > D. Alvarado wrote:[color=green]
      > > Hello,
      > > I am trying to find the <TITLE> element of my document. Normally
      > >
      > > alert(document. title);
      > >
      > > works just fine, but when this statement is within a page that is a
      > > frame in a larger document, the above call always returns the title of
      > > the parent (container) page. Is it possible through JS to deduce the
      > > <TITLE> element of the current page, even if that page is a frame?
      > >
      > > Much thanks - Dave[/color]
      >
      > alert(top.docum ent.title);
      >
      > Mick[/color]

      Comment

      • Ivo

        #4
        Re: How do I get &lt;TITLE&gt ; from frame?

        "D. Alvarado" <laredotornado@ zipmail.com> wrote in message
        news:9fe1f2ad.0 402221605.6c845 76@posting.goog le.com...[color=blue]
        > Thanks for the reply, but I think I misphrased my question. If my
        > "top" document is:
        >
        > <html>
        > <head><title>To p</title></head>
        > <body>
        > <table>
        > <tr><td><ifra me width="200" height="300" src="frame.htm"
        > name="n"></iframe></td></tr>
        > </table>
        > </body>
        > </html>
        >
        > and my frame, "frame.htm" is:
        >
        > <html>
        > <head><title>Fr ame</title></head>
        > <body>
        > <script type="text/javascript">
        > alert(document. title);
        > </script>
        > </body>
        > </html>
        >
        > I want the alert to say "Frame" not "Top," which is what displays with
        > the current text or even if I include the suggestion
        > "alert(top.docu ment.title)". Again, much thanks if someone can crack
        > this enigmatic problem. -[/color]

        Weird, which browser are you using? I get the correct titles when trying
        this in IE6/WinME: different results for alert(document. title) and
        alert(top.docum ent.title). Both can even be changed dynamically (although
        there is litle point in doing that with the framed document). Strange is,
        however, that the actual text displayed in the titlebar is not always
        updated, when trying forexample, to make top.document.ti tle=document.ti tle,
        and then there is no way to confirm if it worked as the top.document.ti tle
        string will reflect the new value.
        Ivo


        Comment

        Working...