Export (0) Print
Expand All
all
alt
ch
dir
id
min
rel
top
url
URL
urn
Expand Minimize

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