Home Articles FAQs XREF Games Software Instant Books About Feedback Search Site-Map
irt.org logo

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

irt.org | Knowledge Base | JavaScript | Frame | Q1692 [ previous next ]

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

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?'


Provide feedback ...
AddThis Social Bookmark Button

Provide feedback ... AddThis Social Bookmark Button


Last Updated: 30th March 2008. Maintained by: Martin Webb and Michel Plungjan
irt.org liability, trademark, document use, privacy statement and software licensing rules apply.
Copyright © 1996-2008 irt.org, All Rights Reserved.