spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / dhtml / diner / realpos1

Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?

Determining Element Page Coordinates, Part 1
IE for Windows, NS6

Parent Elements - elementReference.parentElement

The parentElement property is supported only by Internet Explorer 4+ and is part of the original IE DOM specification.
It is not part of any public standard specification.
It is documented at MSDN.

Consider the image (WebReference logo) in the left column. The HTML that the image resides in is:

<HTML>
  <HEAD></HEAD>
  <BODY>
    ...
    <SPAN>
      <TABLE>
        <TR>
          ...
          <TD>
            <TABLE>
              <TR>
                <TD>
                  <IMG ID="TheWRImage" SRC="wrlogo.gif">
                </TD>
                ...
              </TR>
            </TABLE>
          </TD>
        </TR>
      </TABLE>
    </SPAN>
  </BODY>
</HTML>

The table below illustrates the document hierarchy of this page in relation to the WR logo image and with reference to the parentElement property of elements.

Note:
The bordered area labelled: Your Browser was dynamically generated when the page was loaded. It displays information only in IEWin and NS6+, the browsers currently under consideration.
In older NS6 versions, there are timing problems with the onload event firing. If you are using such a browser you might not see information displayed in the bordered area. Refresh the page until you do.

The remainder of the table lists the document hierarchy by tag name starting with the immediate parentElement of the image and working up to the top-most element, for the browsers addressed by this article.

Parent Elements    -     elementReference.parentElement
Your browser: n/a
TheWRImage | TD | TR | TBODY | TABLE | TD | TR | TBODY | TABLE | SPAN | BODY | HTML | null
TheWRImage | n/a

All versions of IE return the same results.

The parentElement of the top-most element in the hierarchy (<HTML>) returns as null.

This is useful for testing an element's nested position. Example:

    elementReference.bIsTopLevel = (elementReference.parentElement == null);

Let's repeat this example with parent nodes.




Produced by Peter Belesis and

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

All Rights Reserved. Legal Notices.
Created: May 18, 1998
Revised: August 26, 2002

URL: http://www.webreference.com/dhtml/diner/realpos1/3.html