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!

write to an iframe

Status
Not open for further replies.

NateBro

Programmer
Sep 1, 2004
233
US
i have used it before i just can't seem to remember how.

so something like..
i know its not close, but just to be clear what i'm talking about.



document.iframe.write();



 
With the help of this article here:


(found using Google), I came up with this:

Code:
<html>
<head>
	<script type="text/javascript">
	<!--
		function populateIframe() {
			var ifrm = document.getElementById('myIframe');
			ifrm = (ifrm.contentWindow) ? ifrm.contentWindow : (ifrm.contentDocument.document) ? ifrm.contentDocument.document : ifrm.contentDocument;
			ifrm.document.open();
			ifrm.document.write('Hello World!');
			ifrm.document.close();
		}
	//-->
	</script>
</head>
<body onload="populateIframe();">
	<iframe id="myIframe"></iframe>
</body>
</html>

It works in IE6, FF1, NN7, and Opera7. It probably works in other browsers, too.

Hope this helps,
Dan


The answers you get are only as good as the information you give!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top