Click to See Complete Forum and Search --> : <title> + js?
smokingkills
04-09-2003, 09:46 AM
:)
ok so i have 1 page which has a few child pages within it (iframes)
I have a "<title>sitename | home</title>" on the parent page, but i need to be able to set the title status from one of the child pages. Is there any js that will allow me to do this?:confused:
gil davis
04-09-2003, 10:06 AM
In the newest browsers you can change the document.title at any time.document.title = "whatever";
In older browsers, you can only change the document.title while the document is still loading. Once the HEAD section is complete, the document.title becomes read-only.
smokingkills
04-09-2003, 10:08 AM
so if i remove all <title>...</title> tags from all pages, except the relevant child page, it will work?
surely this js will run in the <head>...</head> anyway?
edit: what i mean is, will only the parent pages <title> show on the browser?
smokingkills
04-09-2003, 10:16 AM
hmm. well i tried a few things and no, it's pooped.
can i not set up something like:
document.title="[titlevar]";
on the parent page, and have the variable 'titlevar' set onLoad of the iframe?
won't the parent page wait for it?
gil davis
04-09-2003, 10:23 AM
Here is an example:
frametitle.htm:
<head>
<title>Frameset Title Test</title>
</head>
<frameset rows="50%,*">
<frame name="f1" src="f1a.htm">
<frame name="f2" src="blank.htm">
</frameset>
f1a.htm:
<a href="f2a.htm">load next page</a>
f2a.htm:
<script>
window.top.document.title = "TADA!";
</script>
When you load frametitle.htm, the title is "Frameset Title Test". When you click the link in the top frame, the title will change to "TADA!" in NS 6 and IE 5.5. It will not change in NS 4. Those are the only browsers I have available for test.
smokingkills
04-09-2003, 10:26 AM
ah good news, thats great.
I'll just set a standard title in there for load then (for older browsers)
and i can use this on any subsequent iframe page. lovely thanks alot!;)