Why parentNode has no properties?

Discussion in 'Javascript' started by RC, May 31, 2007.

  1. RC

    RC Guest

    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!
    RC, May 31, 2007
    #1
    1. Advertising

  2. 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/
    Martin Honnen, May 31, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    0
    Views:
    3,438
  2. NotGiven
    Replies:
    0
    Views:
    497
    NotGiven
    Sep 17, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,739
    Smokey Grindel
    Dec 2, 2006
  4. RC
    Replies:
    1
    Views:
    1,296
    Martin Honnen
    May 31, 2007
  5. pxpilot

    XmlNode ParentNode???

    pxpilot, Feb 23, 2008, in forum: ASP .Net
    Replies:
    1
    Views:
    454
    Michael Nemtsev [MVP]
    Feb 23, 2008
Loading...

Share This Page