Retrieves the window object of the specified frame or iframe.
Syntax
| JavaScript | |
|---|
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
Build date: 11/28/2012