Windows apps
Collapse the table of content
Expand the table of content
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

contentWindow property

Retrieves the window object of the specified frame or iframe.

Syntax

JavaScript

p = object.contentWindow

 

Property values

Type: Object

the window object.

Remarks

This property is useful if you do not know the id of the frame or iframe you are accessing through a collection.

Examples

The following example shows how to use the contentWindow property to change the URL of window objects contained inside several iframe objects.

Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/contentWindowEX1.htm



<html>
<head>
<script type="text/javascript">
  function fnNavigate() {
    for (i = 0; i < document.all.length; i++) {
      if (document.all(i).tagName == "iframe") {
        document.all(i).contentWindow.location = "http://www.msn.com";
      }
    }
  }
</script>
</head>
<body>
<button onclick="fnNavigate();">Navigate Frames</button>
<p/>
<iframe src="http://www.microsoft.com" style="width:100%;height:150px;">
</iframe>
<p/>
<iframe src="http://www.microsoft.com" style="width:100%;height:150px;">
</iframe>
<p/>
<iframe src="http://www.microsoft.com" style="width:100%;height:150px;"/>
</iframe>
</body>
</html>	


See also

frame
iframe
frameElement

 

 

Show:
© 2017 Microsoft