I was doing some playing around with accessing frames on the DOM via window.top.frames, and noticed that the collection doesn’t seem to be populated until after the actual <iframe> tag. My example:
<html>
<head>
<title>Test Page</title>
<script language=”javascript” type=”text/javascript”>
var oFrames = window.top.frames;
</script>
</head>
<body>
<script language=”javascript” type=”text/javascript”>
alert(“before: ” + oFrames.length);
</script>
<iframe id=”myframe” src=”testing/jreese/test.asp” name=”ok”></iframe>
<script language=”javascript” type=”text/javascript”>
alert(“after: ” + oFrames.length);
</script>
</body>
</html>
demonstrates how the count changes. Is there a better way to access frames/iframes rather than using the frames collection? If my findings are correct, does this mean you’re not able to use the frames[] collection in a .js file that’s included at the top of a page to access iframes that appear in the body of the page?