Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Modify a HTML loaded into a iframe

0 views
Skip to first unread message

Guilherme Menezes

unread,
Sep 5, 2008, 5:56:58 PM9/5/08
to
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.

Thank you in advance for your replies!

Guilherme Menezes.

Eric H. Jung

unread,
Sep 6, 2008, 9:08:22 PM9/6/08
to dev-ext...@lists.mozilla.org

----- 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



Guilherme Menezes

unread,
Sep 8, 2008, 9:22:50 AM9/8/08
to

Thank you. This will probably work for me.

Guilherme.

0 new messages