contentWindow
all
alt
ch
dir
id
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.



<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