Welcome to WebmasterWorld Guest from 50.17.16.177

Forum Moderators: open

Message Too Old, No Replies

How to get contentWindow of IFrameElement in opera 7?

     
6:49 am on Jun 4, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:372
votes: 0


how?
thx
8:58 am on June 4, 2003 (gmt 0)

Senior Member

WebmasterWorld Senior Member tedster is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:May 26, 2000
posts:37301
votes: 0


contentWindow is IE only, non-standard code.

Just assign your iframe an id and access it that way.

10:48 am on June 4, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:372
votes: 0


i just wrote "contentWindow" to express what i need

in IE:
<iframe id="a"></iframe>
<script>
var a = document.getElementById('a');
alert(a.contentWindow.self);
</script>
i get [object]

and u think i can get a.self instead of a.contentWindow.self in opera 7?

and how do u document.write into a iframe?

5:29 pm on June 6, 2003 (gmt 0)

Preferred Member

10+ Year Member

joined:Nov 19, 2002
posts:372
votes: 0


ok, it's a display:none problem

opera7 do not present window object of iframe if it's hidden

<iframe name=... id=...>required text here</iframe>

<script>
var ifm = document.getElementById("iframeElementId");
alert(ifm.contentDocument); // null
if (self.iframeName == ifm) { // true for opera7 when iframe display:none
ifm.style.display = "block";
ifm.style.display = "none";
alert(ifm.contentDocument); // still null

setTimeout("alert(ifm.contentDocument);", 1000) // object [HTMLDocumentElement]
alert(self.iframeName == ifm); // false
}

</script>