How to change iframe content in dom using firefox extension code?

I would like to change the page shown in my browser using the Firefox extension (add-in) that I wrote. I can get iframes pages as XPCNativeWrapper 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 could not get to the contents of iframes, not to mention changing it.

How can I change the contents of an iframe in dom?

+3
source share
2 answers

I think you want elmInput.contentDocument

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

Source: https://habr.com/ru/post/1763766/


All Articles