Click to See Complete Forum and Search --> : r/w iframe


ibidris2003
08-20-2003, 05:27 AM
Hi,

How do I write and read to from iframe with Javascript?

I used this code but it only works in IE:
<script language="JavaScript"><!--
window.document.frames['iframepreview'].document.open();
window.document.frames['iframepreview'].document.write('Hello world');
window.document.frames['iframepreview'].document.close();
//--></script>

How do I get it to work with other browsers?

Thanks.

http://galileo.spaceports.com/~ibidris/

Khalid Ali
08-20-2003, 07:55 AM
to write to document..whchi you have used in yr coe should be like this

parent.frameName.docuement.open();
.....write()
.....close();


My personal choice will be target the particular part or element in the iframe document and write to that using innerHTML

suppose you have a div element inthe iframe
<div id="data"></div>

you cna target this dive to pust any data you want

parent.formName.document.getElementById("data").innerHTML = "any text data could go here";

and to read back, this will give you the ability to just do this
alert(parent.formName.document.getElementById("data").innerHTML)