I'm new into Mozilla extensions development, and I have a short
question.
First of all, I have an iframe element which always load the same HTML
document from my personal HTTP server (I have created the document and
have control over its contents.) I need change the content of the HTML
loaded into this iframe from the extension code (for example, by
changing the src field of an image). Is it possible? How can I do it?
I've been searching for it for some hours now, maybe some of you have
had the same problem.
Thank you in advance for your replies!
Guilherme Menezes.
----- Original Message ----
> From: Guilherme Menezes <guilherme....@gmail.com>
> To: dev-ext...@lists.mozilla.org
> Sent: Friday, September 5, 2008 5:56:58 PM
> Subject: Modify a HTML loaded into a iframe
>
> Hi,
>
> I'm new into Mozilla extensions development, and I have a short
> question.
>
> First of all, I have an iframe element which always load the same HTML
> document from my personal HTTP server (I have created the document and
> have control over its contents.) I need change the content of the HTML
> loaded into this iframe from the extension code (for example, by
> changing the src field of an image). Is it possible? How can I do it?
>
> I've been searching for it for some hours now, maybe some of you have
> had the same problem.
Yes, it's possible and is done often. The basic idea is:
1. Attach a load event listener to the window/iframe/whatever
2. In your event listener, get the DOM id of the HTML you want to change.
3. Change content using the DOM manipulation methods (appendChild, removeNode, etc) or the innerHTML property/attribute
HTH,
Eric
Thank you. This will probably work for me.
Guilherme.