Reputation: 2817
I am trying to build a browser extension using KangoExtensions.
I'm appending the following iframe to the body:
<iframe id="iframe" name="iframe" allowtransparency="yes"
style="position: absolute; top: -41px; left: 0px; right: 0px; width: 100%; height: 41px; z-index: 10000; border: 0px none;">
</iframe>
After I append the iframe I try to write the content:
window.onload= function(){
$(iframe).ready(function(){
var iframeDocument = false;
if(iframe.contentDocument) {
iframeDocument = iframe.contentDocument;
} else if(iframe.contentWindow) {
iframeDocument = iframe.contentWindow.document;
} else if(window.frames['iframe'].document) {
iframeDocument = window.frames['iframe'].document;
}
if(iframeDocument) {
iframeDocument.open();
iframeDocument.write(content);
}
});
};
The extension works in all browsers (Chrome, Opera, IE) but in Firefox it does not write anything to the iframe. If I use iframeDocument.body.innerHTML = content;
the content is visible for a few milliseconds and then disappears. I only see a gray(ish) rectangle.
Are there some limitations to what one can do with iframes in a Firefox extension?
Upvotes: 2
Views: 974
Reputation: 2077
Seems iframe not compeltly loaded when you trying to modify it.
Change $(iframe).ready(function(){...})
to iframe.addEventListener('load', function(){...})
.
Upvotes: 3