You are here: Reference > JavaScript > client-side > HTML DOM > properties > parentWindow (document)
parentWindow property (document)
The parentWindow property is only supported in Internet Explorer.
In other browsers, use the defaultView property for similar functionality.
Syntax:
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:
|
|||||||
<head> <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); } } </script> </head> <body> <iframe src="frame1.htm"></iframe> <iframe src="frame2.htm"></iframe> <br /><br /> <button onclick="GetLocations ();">Get the location of the frames</button> </body> |
|||||||
|
|||||||
Did you find this example helpful?
|
Supported by objects:
Related pages:
External links:
User Contributed Comments