Shahin Saneinejad wrote:
I've got unparsed HTML in memory (as a string), and I want to display it in an iframe without writing to a file first. I think this means I have to work around the iframe's src attribute.

iframe's docShell looks promising, but I think I have to put my string through an InputStream to use nsIDocShell's loadStream(nsIInputStream) method. Does anyone know which input stream implementation to use, or better, the general process by which this might be done? I'm leaning toward nsIMIMEInputStream, just because 'MIME' reminds me of a webpage server... but all in all, the whole thing seems to me like an overly complex solution to a very simple problem. Seen anything like this? Ideas?

Thanks,

Shahin


Hi,

Just use the innerHTML property of your iframe element this way:

var HTMLcontent = '<h1>This is an example</h1>';
var iframeId = 'iFrame';  //replace iFrame with your actual iframe ID
var iframeDoc = document.getElementById(iframeId).contentDocument;
var iframeBody = iframeDoc.body;
iframeBody.innerHTML = HTMLcontent;

That's all: your iframe content is now: <h1>This is an example</h1>

Note that innerHTML is *not* a W3C DOM standard property.

Daniel
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to