Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Javascript > Why parentNode has no properties?

Reply
Thread Tools

Why parentNode has no properties?

 
 
RC
Guest
Posts: n/a
 
      05-31-2007
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!
 
Reply With Quote
 
 
 
 
Martin Honnen
Guest
Posts: n/a
 
      05-31-2007
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
XmlNode ParentNode??? pxpilot ASP .Net 1 02-23-2008 12:35 PM
Why parentNode has no properties? RC XML 1 05-31-2007 02:54 PM
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
Check childnodes when checking parentnode in Treeview (ASP.NET 2.0) dolberg@gmail.com ASP .Net 0 09-26-2005 09:18 AM
code "insertHere.parentNode.insertBefore(newfields,insertHere);" over-writing itself NotGiven XML 0 09-17-2004 04:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57