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

Q1692 How do I apply the title of a page that gets loaded inside a frame to the top frame?

You are here: irt.org | FAQ | JavaScript | Frame | Q1692 [ previous next ]

It's very easy...

Put this script right after the </title> tag in your header of each web page that get loaded *inside* the frame whose title you want changed:

This script will apply the page's title to the top frame. The new title will change automatically.

Assuming that the pages you are loading into the frame window are on the SAME server, it will work fine. Do not use absolute URLs when loading web pages into a frame, it could cause a security exception.

<script language="JavaScript"><!--
if (top != self) top.document.title = document.title;
//--></script>

Submitted by Gerard J. Pinzone

Try going in a loop to find the parent of the frame till you reach the top level. There you assign the title to the top most frame.

var _p = this.parent;
var _title = "THE PAGE TITLE YOU WANT TO SHOW";
while (_p != this) {
  if (_p == _p.parent) { break; }
  _p = _p.parent;
}
_p.document.title=_title;

Submitted by Anurag Varshney

Feedback on 'Q1692 How do I apply the title of a page that gets loaded inside a frame to the top frame?'

©2018 Martin Webb