Home Articles FAQs XREF Games Software Instant Books BBS About FOLDOC RFCs Feedback Sitemap
irt.Org

BBS: Re: changing titles in frameset with javascript - August 03, 1998 at 17:39:35

You are here: irt.org | BBS | Re: changing titles in frameset with javascript [This BBS is closed]

Posted by Pat J. Magnan on August 03, 1998 at 17:39:35:

In Reply to: Re: changing titles in frameset with javascript posted by Martin Webb on July 28, 1998 at 07:12:16:

: : Does anyone of you know wether it is possible to change the title of a frameset with javascript when you load a new page in to the content section of the frameset.

: The windows title property is read only - therefore you cannot change the title once it has been set.

While the title property is read only, you can achieve an effect which simulates changing the title in context.

let's say you have two frames, one called 'nav' and one called 'main'. By using a script like the following, you can have the title change, as you load new frames into 'main'.

<script ,etc>

function loadPage (myurl, mytitle) {

window.parent.document.close ();

window.parent.document.write ('<html><head><title>');
window.parent.document.write (mytitle);
window.parent.document.write ('</title></head>');
window.parent.document.write ('<frameset cols=\"20%,*\">');
window.parent.document.write ('<frame name=\"nav\" src=\"nav.html\">');
window.parent.document.write ('<frame name=\"main\" src=\"' + myurl + '\">');
window.parent.document.write ('</frameset>');

This script goes into the nav.html file, which, is loaded every time a user clicks a link, by the onClick, as follows:

<a href="new_main.html" onClick="loadPage ('new_href.html', 'new title');" target="main">Link goes here</a>

The target is only there for JavaScript incapable browsers.

The major disadvantage is that the entire site is being reloaded, thus eliminating the advantage of having the frames in the first place. I'd recommend only using this for pages that you find it extremely important to change the titles for, lest you slow down your entire site.

Cheers,


Follow-ups:

You are here: irt.org | BBS | Re: changing titles in frameset with javascript [This BBS is closed]

©2018 Martin Webb