Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsGeneralPHPASPPerlColdFusionFlashHTML, CSS, ScriptsBrowsers

Webmaster Forum / HTML, CSS, Scripts / JavaScript / May 2007



Tip: Looking for answers? Try searching our database.

Why parentNode has no properties?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RC - 31 May 2007 14:59 GMT
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 - 31 May 2007 15:54 GMT
>         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).

Signature

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

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.