How to change the <title> when am using frames
Moderator: General Moderators
-
Xanthopoulos C.
- Forum Newbie
- Posts: 3
- Joined: Thu Dec 07, 2006 2:33 am
How to change the <title> when am using frames
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
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
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.
Code: Select all
document.title = 'New Title';- evilchris2003
- Forum Contributor
- Posts: 106
- Joined: Sun Nov 12, 2006 6:43 am
- Location: Derby, UK
-
Xanthopoulos C.
- Forum Newbie
- Posts: 3
- Joined: Thu Dec 07, 2006 2:33 am
Thank you a lot for your time evilchris2003 and Zoxive
. But as you said I have to use them because it is a part of my University's project.
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".
I couldn't agree with you more'm sure i'm not alone
I want to "drill" the title of the page from the inner frame.document.title = 'New Title';
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".
- evilchris2003
- Forum Contributor
- Posts: 106
- Joined: Sun Nov 12, 2006 6:43 am
- Location: Derby, UK
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
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
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');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
- RobertGonzalez
- Site Administrator
- Posts: 14293
- Joined: Tue Sep 09, 2003 6:04 pm
- Location: Fremont, CA, USA
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>-
Xanthopoulos C.
- Forum Newbie
- Posts: 3
- Joined: Thu Dec 07, 2006 2:33 am
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