Well, this is my first time we take IFrames seriously, and I can't figure out a few things:
First, the sample code that I am testing with
<head> <script type="text/javascript"> function init(){ console.log("IFrame content: " + window.frames['i1'].document.getElementsByTagName('body')[0].innerHTML); } </script> </head> <body onload="init();"> <iframe name="i1" src="foo.txt"/> </body>
the file "foo.txt" is as follows:
sample text file
Questions:
1) the iframe seems to behave like an HTML document, and the text of the file is actually part of the body. What for? Is the IFrame rule an HTML document. Is it not possible that the contents of an iframe are just text?
2) For some reason, the contents of the file are wrapped inside the pre tag. Why is this so? It's always like this?
3) My access method in javascript works, but is there any other alternative? [native js solutions please] If the content is wrapped in a pre tag, then I really need to search inside the pre tag and not look for innerHTML
Rajat source share