Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the contents of an iframe 1

Status
Not open for further replies.

Bong

Programmer
Dec 22, 1999
2,063
US
Greeting,
I searched a little but couldn't find anything I was able to understand. My goal is load some data into a frame (iframe), manipulate it a little, and then replace the contents of the frame with this (now manipulated) text. To that end, I'm only at the point of trying, without success, to get the contents of the frame at all:
Code:
<html>
<head></head>
<body>
iframe test
<iframe id="if1" src="file://h:/java/zlnch.txt" align="right">
</iframe>
<div id="d1"></div>
<script type="text/javascript">
[red]document.getElementById("d1").innerHTML=if1.document.body.innerHTML[/red]
</script>
</body></html>
does not work

_________________
Bob Rashkin
 
Your text file has a body tag?

Probably not. Which is why it's not able to be recognised by the document object model.

[sub]Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.
[/sub]

Webflo
 
OK. I was just flailing. I found that code in an example on the Web. My text file is a simple CSV file. There are no tags at all. So I guess my question is, what is the proper syntax to return a string containing the contents of the iframe (which in turn is the contents of the text file)?

_________________
Bob Rashkin
 
Such as this.
[tt]
<html>
<head></head>
<body>
iframe test
<iframe id="if1" src="file://h:/java/zlnch.txt" align="right">
</iframe>
<div id="d1"></div>
<script type="text/javascript">
[blue]function doit() {[/blue]
document.getElementById("d1").innerHTML=[red]document.getElementById("if1").contentWindow[/red].document.body.innerHTML
[blue]}
window.onload=doit;[/blue]
</script>
</body></html>
[/tt]
 
Perfect, tsuji.
Thanks.

_________________
Bob Rashkin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top