VK wrote a bunch of nonsense, to which Andrew Poulos replied:
Sorry, but you've confused me. In IE 5, from a frameset, instead of doing:
var mypage = window.frames['mainFrame'];
var allEl = mypage.document.all;
I should do:
var allEl = self.frames['mainFrame'].document.all;
Isn't window.frames and self.frames not the say thing?
Yes, you're right, because window === self
And of course he implemented the very DOM methods that you are trying
to account for not having.
I think I see the problem, here.
Lacking a getElementById, you're obviously being forced to use the .all
collection-- that much is readily apparent. But after fiddling with it
a bit, I was a bit miffed to note that given:
<html>
<frameset>
<frame id=frameA src=/test.html>
<frame id=frameB src=/test.html>
</frameset>
</html>
Oddly, the following will be true:
window.document.all === window.frames['frameB'].document.all
window.document.body.innerHTML ===
window.frames['frameB'].document.innerHTML
window.frames[1].all.length == 0 ???
Here was one solution (and yes, I know it's ugly, but it worked for
throwing together a quick test):
<html>
<head>
<script>
function loaded( x ) {
alert( x.body.innerHTML );
}
</script>
<frameset rows=50%,50%>
<frame src=/test.html id=frameA></frame>
<frame src=/test.html id=frameB></frame>
</frameset>
</html>
Then, in the <body> tag of /test.html, I added this:
onload=top.loaded&&top.loaded(window.document)
It worked, but it's a bad way to do it and is very easily broken.
I also found that this worked, which you may find more useful:
<html>
<head>
<script>
function check( ) {
if( window.frames['frameB'].document.readyState == 'complete' )
alert( window.frames['frameB'].document.all.length );
else
setTimeout( check, 250 );
}
</script>
<frameset rows=50%,50%>
<frame src=/test.html id=frameA onload=check()></frame>
<frame src=/test.html id=frameB></frame>
</frameset>
</html>
Apparently, until the document in frameB is actually built in the
browser, certain of its properties will refer to the parent window's
properties, in particular .all and .body
This behaviour is not at all what I would expect.
The onload in the <frame> element will fire as soon as the element is
loaded-- not necessarily the document to which it refers. The second
example above checks the referenced document's readyState every
quarter-second until it comes back as 'complete'. I'm not sure if
..readyState is implemented identically in IE4 -- you'll have to check
that.
Don't know if this information will help lead you to the specific
solution you're looking for, but hopefully it's better than nothing.