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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

<IFRAME> CONTENT TO <TEXTAREA>

Status
Not open for further replies.

Deleted

Technical User
Jul 17, 2003
470
US
O.K. Here is the code I have.. The content of the <iframe> even though it exists doesn't return squat.

Any help on this would be most excellent.

Code:
<textarea name="content" style="height:250;width:448"></textarea>

<iframe id="hidden" style="height:30;width:100" src="?mode=email;cmd=load;string=[%form.string%]"></iframe>
             
<script language="javascript">
<!--//
alert(document.getElementById('hidden').contentWindow.document.body.innerHTML);
// document.this_form.content.value = document.getElementById('hidden').document.body.innerHTML;
//-->       
</script>

 
UnixJunky,

Maybe this will give you a start:

Code:
<script type="text/javascript">

function getIF(){
var field = document.forms[0].elements['t1'];
field.value = ifrm.document.getElementsByTagName('body')[0].innerHTML;
}

function writeHTML(){
var HTML = "<html>\n\
<body><p>This is a test</p></body>\n\
</body></html>";

ifrm.document.open();
ifrm.document.write(HTML);
ifrm.document.close();
}

//Risky, consider page load time
setTimeout('getIF()', 1000);
</script>

</head>
<body><center>
<h2>IFRAME</h2>
<br>
<iframe name="ifrm" height="300" width="550" src="">
</iframe>

<script>
writeHTML();
</script>

<form>
<textarea name="t1" rows="4" cols="30">
</textarea>


Thanks,
 
This seem to do it. I guess there was a timing issue between the HTML and IFRAME loading. Thanks for your help.

Code:
<script language="javascript">
<!--//
setTimeout('copyText()', 1000);

function copyText() {
        document.this_form.content.value = document.getElementById('output').document.body.innerHTML;
}
//-->
</script>

 
Whoops.. Let me try that one again shall we.

Code:
<textarea name="content" style="height:250;width:448"></textarea>

<iframe id="hidden" style="visibility:hidden" src="?mode=email;cmd=load;string=[%form.string%]"></iframe>      
             
<script language="javascript">
<!--//
setTimeout('copyText()', 1000);

function copyText() {
        document.this_form.content.value = document.getElementById('hidden').contentWindow.document.body.innerHTML;
}
//-->
</script>

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top