Log in

View Full Version : Changing the Title of a Frameset Document



Anon
03-25-2008, 12:24 AM
As the title states, I want a script that will change the title of the document when one of the frames changes.

My frameset document has run of the mill code, so that won't be very difficult.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Welcome! </title>
</head>

<FRAMESET border=0 frameSpacing=0 frameBorder=0 cols=220,*>
<FRAME name=MENU src="Frameset-Left-Menu.html" noresize>

<FRAME name=VIEW src="Frameset-Center-Home.html">
</FRAMESET><noframes></noframes>
</FRAMESET>
</html>


In case I did not make it clear enough earlier, what I want the frameset document to do is have the title (in red) change when frameset "VIEW" changes.


Any help would be greatly appreciated.

Regards
-Anon

Nile
03-25-2008, 02:58 AM
Try putting this on your page:


<script type="text/javascript">
a = document.getElementById('frame_v');
if(a.name != "VIEW"){
document.title="The view has changed!";
} else {
document.title=document.title;
}
</script>

Then switch:


<FRAME name=VIEW src="Frameset-Center-Home.html">

To:


<FRAME name=VIEW src="Frameset-Center-Home.html" id="frame_v">

Anon
03-25-2008, 09:23 PM
Thanks for your help, but the code didn't work. But then again I may havr placed it in the wrong section.

I tried placing it in the head of the document,
<head>
<script type="text/javascript">
a = document.getElementById('frame_v');
if(a.name != "VIEW"){
document.title="The view has changed!";
} else {
document.title=document.title;
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title> Welcome! </title>
</head>

And after the head,


</head>
<script type="text/javascript">
a = document.getElementById('frame_v');
if(a.name != "VIEW"){
document.title="The view has changed!";
} else {
document.title=document.title;
}
</script>

But since this is a frameset document, there is no body tag, where I would normally place a code if none of these worked. Please tell me if I placed the code in the wrong place.

Oh, I did remember to place the other section of the code.

Thanks for your help!

-Anon

Nile
03-26-2008, 12:10 AM
Well, can you please tell me what you are gonna do with the name changes?
Like are you gonna have JavaScript change the names? If you have javaScript change the names you can put it in that in the function to change the document title. Example:


function change_name(){
document.getElementById('id').name="Hey";
document.title="The id.name has been changed *gasp*!";
}

Anon
03-26-2008, 11:33 AM
What I want to happen is have the title of the Frameset document be the same as the title of "VIEW".

I thought that maybe it could be:
<script type="text/javascript">
a = document.getElementById('frame_v');
if(a.name != "VIEW"){
document.title=frame_v.title;
} else {
document.title=document.title;
}
</script>

But I don't quite know if that would work.

Thanks for the help so far.

-Anon

Nile
03-26-2008, 11:49 AM
I don't think that you can change the title of the framset. Your code also won't work because your referring to the id being a name...