Forum Moderators: open

Message Too Old, No Replies

Frames Titles

         

Old_Honky

4:33 pm on Jun 27, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



This may be in the wrong forum, please move it if necessary.

In a simple frameset of two frames left for navigation and right for main content.

Is it possible to make the <title>in the frames page change dynamically to be the same as the <title> of the page that appears in the main frame.

encyclo

5:12 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Assuming the frames are from the same domain, you could try this Javascript in the main content frame (I got this from tedster BTW, I haven't tested it):

<script type="text/javascript">
void(parent.document.title='Title I Really Want');
</script>

tedster

5:17 pm on Jun 27, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



encyclo's got it - I've been using this on several frameset pages for years - it "works a treat", as my UK friends say.

I'm not sure of how to dynamically pick up the existing title tag - you might experiment with this:

<script type="text/javascript">
void(parent.document.title=document.title);
</script>

Old_Honky

10:18 am on Jun 28, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



Thanks for the script it almost does what I want, I've tried a few variations but I can't get it to pick up the title from the main page. I know very little about javascript so if anyone has any further ideas they would be very welcome.

Old_Honky

5:22 pm on Jun 29, 2005 (gmt 0)

10+ Year Member Top Contributors Of The Month



Just for the record, and in case anyone else has a similar problem, I received the following solution via another forum.

Put the following code anywhere in the <head> or <frameset> tags


<script type="text/javascript">
function changeTitle()
{
if (top.frames['main'].document.title)
{
top.document.title=top.frames['main'].document.title;
}
}
</script>

Then add the following onload handler to the <frame> tag of the frame from which you get the title.
ONLOAD="changeTitle();"

It works perfectly.