Page 1 of 1
How to change the <title> when am using frames
Posted: Thu Dec 07, 2006 2:54 am
by Xanthopoulos C.
Hi all,
I am sure you all know that when you are using frames to a webpage you are not able to change the <title> text when surfing from a frame to another for example "MyWebpage - Home" to "My webpage - Contact".
I am trying to find a way through php that I will be able to read a variable from the html file of the <iframe> and then printing it to the main's fraim <title>.
The problem is that I don't know a way to link those two files.
If there is a different solution, I will be glad to hear it.
Thank you all in advance
Posted: Thu Dec 07, 2006 2:58 am
by Zoxive
Is there a reason to use frames? I personally hate Frames, and i'm sure i'm not alone. But you could use javascript to change the title if you really need to.
This wont be good for search engine results, and frames never where good for those either.
Posted: Thu Dec 07, 2006 4:08 am
by evilchris2003
Frames are barely used anymore
i first learnt HTML using frames and found them clunky and disjointed
tables and CSS are much better for aligning your data
Posted: Thu Dec 07, 2006 1:09 pm
by Xanthopoulos C.
Thank you a lot for your time evilchris2003 and Zoxive
'm sure i'm not alone
I couldn't agree with you more

. But as you said I have to use them because it is a part of my University's project.
document.title = 'New Title';
I want to "drill" the title of the page from the inner frame.
For example when I am using the menu link "contact" at the main frame with the target="innerframe" I would like the <title> of the page to change to "Webpage - Contact".
Another problem is that my menu is a .swf file so I can't just add a event OnClick="The javascript you gave me".
Posted: Thu Dec 07, 2006 5:09 pm
by evilchris2003
personally i use an include file for the head of all my pages (header.inc)
and call the page name like this where $page_title is a variable in the header
Code: Select all
$page_title = 'Webpage Contacts';
include ('./header.inc');
but i really dont see how with out JS you are going to allow the <title> tag to be altered
as what you are asking is client side and as is so often pointed out on this forum php is server side
just a thought assuming the user has to click a link to view that particular page
try an switch statement where if the user clicks a particular link set $page_title then use $_POST to return the title on the following page
Posted: Thu Dec 07, 2006 5:25 pm
by RobertGonzalez
Code: Select all
<?php
// Pretty much you can do anything you want here, even pick the pages that fill the frame
$page_title = 'Contact';
$top_frame = 'pages/topper.php?somevar=just_for_fun';
$bottom_frame = 'index.php?page=contact';
?>
<!-- php page contact.php -->
<html>
<head>
<title><?php echo $page_title; ?></title>
</head>
<!-- php page contact.php -->
<frameset cols="100%">
<frameset rows="61px,*">
<frame src="<?php echo $top_frame; ?>" scrolling="no" noresize>
<frame src="<?php echo $bottom_frame; ?>" scrolling="auto" noresize>
</frameset>
</frameset>
</html>
Posted: Fri Dec 08, 2006 6:33 am
by Xanthopoulos C.
Thank you a lot, problem solved with javascript
Code: Select all
top.document.title="Webpage - the_title_of_the_inner_frame";
//To every .htm file that opens to the inner frame
Posted: Fri Dec 08, 2006 6:47 am
by m3mn0n
Moving to client side.