Thariama
Thariama

Reputation: 50832

How do i alter the content of an iframe in the dom using firefox extension code?

I would like to alter the page shown in my browser using a firefox extension (add-on) i wrote. I am able to get the page's iframes as XPCNativeWrapper object using:

iframes = window.content.document.getElementsByTagName('iframe')

for (var i = 0; i < iframes.length; i++) {
  var elmInput = iframes[i];
  Firebug.Console.log(elmInput);
}

But i haven't been able to get to the iframes content, not speaking of altering it.

How can i alter the content of an iframe in the dom?

Upvotes: 3

Views: 218

Answers (2)

Tyler
Tyler

Reputation: 22116

I think you want elmInput.contentDocument

Upvotes: 1

Amir Nathoo
Amir Nathoo

Reputation: 1866

for (var i = 0; i < iframes.length; i++) {
    var content = iframes[i].contentWindow.document.body.innerHTML;
    ...
}

Upvotes: 1

Related Questions