You are here: Reference > JavaScript > client-side > HTML DOM > properties > parentWindow (document)

parentWindow property (document)

Browser support:
Returns a reference to the window object that contains the current document.
The parentWindow property is only supported in Internet Explorer. In other browsers, use the defaultView property for similar functionality.


You can find the related objects in the Supported by objects section below.
This property is read-only.

Possible values:

Reference to the parent window object.
Default: this property has no default value.

Example HTML code 1:

This example illustrates the use of the parentWindow property:
    <script type="text/javascript">
        function GetLocationFromDocument (doc) {
            var parWindow = doc.defaultView ? doc.defaultView : doc.parentWindow;
            alert (parWindow.location.href);

        function GetLocations () {
            var frameTags = document.getElementsByTagName ("iframe");
            for (var i = 0; i < frameTags.length; i++) {
                var frameTag = frameTags[i];

                var frameDoc = frameTag.contentDocument ? frameTag.contentDocument : frameTag.contentWindow.document;

                GetLocationFromDocument (frameDoc);
    <iframe src="frame1.htm"></iframe>
    <iframe src="frame2.htm"></iframe>
    <br /><br />
    <button onclick="GetLocations ();">Get the location of the frames</button>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content