contentWindow
all
alt
ch
dir
for
id
low
min
rel
top
url
URL
urn
TOC
Collapse the table of content
Expand the table of content

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:
© 2016 Microsoft