469,602 Members | 1,838 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,602 developers. It's quick & easy.

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
Jul 20 '05 #1
3 9853
D. Alvarado wrote:
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


alert(top.document.title);

Mick
Jul 20 '05 #2
Thanks for the reply, but I think I misphrased my question. If my
"top" document is:

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

and my frame, "frame.htm" is:

<html>
<head><title>Frame</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.document.title)". Again, much thanks if someone can crack
this enigmatic problem. -

Mick White <mw******@BOGUSrochester.rr.com> wrote in message news:<sh*******************@twister.nyroc.rr.com>. ..
D. Alvarado wrote:
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


alert(top.document.title);

Mick

Jul 20 '05 #3
Ivo
"D. Alvarado" <la***********@zipmail.com> wrote in message
news:9f*************************@posting.google.co m...
Thanks for the reply, but I think I misphrased my question. If my
"top" document is:

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

and my frame, "frame.htm" is:

<html>
<head><title>Frame</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.document.title)". Again, much thanks if someone can crack
this enigmatic problem. -


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.document.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.title=document.title,
and then there is no way to confirm if it worked as the top.document.title
string will reflect the new value.
Ivo
Jul 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

13 posts views Thread by mark | last post: by
5 posts views Thread by Info 3000 | last post: by
1 post views Thread by Andreas Klemt | last post: by
6 posts views Thread by Alex | last post: by
8 posts views Thread by DC | last post: by
5 posts views Thread by Carlo Marchesoni | last post: by
15 posts views Thread by Steve B | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.