Not really. document.write() automatically calls document.open() (and document.clear()) on a closed document. Your first attempt wasn't working because .getElementById() returns the
element object, which doesn't have a document property. The second attempt uses a frame reference (same as window.frames.
frame_name), returning the
window object representing the iframe, which has the iframe's document object (like all window objects) as a property. Might try:
Code:
function IFRAME_write(iframe_id, HTML)
{
var IFrameDoc, oIframe = document.getElementById(iframe_id);
if (typeof oIframe != 'undefined')
{
if (oIframe.contentDocument)
IFrameDoc = oIframe.contentDocument;
else if (oIframe.contentWindow)
IFrameDoc = oIframe.contentWindow.document;
else if (oIframe.document)
IFrameDoc = oIframe.document;
if (IFrameDoc)
{
IFrameDoc.write(HTML);
IFrameDoc.close();
}
}
}