Accessing an iFrame's dom from a Firefox Extension
- by luisgo
Hi all,
I've spent a long time trying different things to get this to work but nothing does and documentation is not helping much.
I'm trying to populate a form inside an iframe that I dynamically inject into a page. To inject that iframe I do:
myObject.iframe = document.createElement("iframe");
myObject.iframe.setAttribute("src", data.url);
myObject.iframe.setAttribute("id","extension-iframe");
myObject.window.document.getElementById('publisher').appendChild(myObject.iframe);
myObject.iframe.addEventListener("load", function(){
myObject.populate(data);
}, false);
which works fine and DOES trigger the populate() method. My problem is getting the document or window objects for that iframe. I've tried all of the following:
myObject.iframe.window
myObject.iframe.document
myObject.iframe.content
but these are all undefined.
I also tried passing the event object to that iframe's load event listener and then doing:
event.originalTarget
But that didn't work either.
I am reading the following documentation:
https://developer.mozilla.org/En/Working%5Fwith%5Fwindows%5Fin%5Fchrome%5Fcode
https://developer.mozilla.org/en/Code%5Fsnippets/Interaction%5Fbetween%5Fprivileged%5Fand%5Fnon-privileged%5Fpages
But either I'm not understanding it or it's just not properly explained.
Can anyone shed some light?
Thanks!