Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   XML (http://www.velocityreviews.com/forums/f32-xml.html)
-   -   Why parentNode has no properties? (http://www.velocityreviews.com/forums/t510920-why-parentnode-has-no-properties.html)

RC 05-31-2007 01:59 PM

Why parentNode has no properties?
 
I have a simple test page with frames

<html><title>Title A</title>

<frameset rows="50%,*">
<frame src="frame1.html" name="frame1" />
<frame src="frames.html" name="frame2" />
</frameset>
</html>

In frame1.html I want to get the parent's title and
change it

function changeTitle(newTitle) {

var upperNode = document.parentNode;
var upperTitle = upperNode.title;
alert(upperTitle);
upperNode.title = newTitle;
}


The problem is 2nd line, error message says
upperNode has no properties.

But I check the DOM console in Firefox, it has properties, include the
title.

Please help how to change the Web browser's title?
Thank Q very much!

Martin Honnen 05-31-2007 02:54 PM

Re: Why parentNode has no properties?
 
RC wrote:

> var upperNode = document.parentNode;


The document node is the root of the DOM tree so it does not have a
parent node. If you are scripting a frame and you are looking for the
_parent window_ then use e.g.
window.parent
to access the parent window and then e.g.
window.parent.document.title
to access the title of the document in the parent window (for instance
the title of the frameset document).



--

Martin Honnen
http://JavaScript.FAQTs.com/


All times are GMT. The time now is 07:43 AM.

Powered by vBulletin®. Copyright ©2000 - 2013, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.