Reputation: 3044
We are developing an add-in, and would like to have the content script being injected into the top page and all frames. However we found that the content scripts cannot be injected into iframe with src as "about:blank" or "javascript:...".
Any comment/suggestion?
sample page-mod:
require("sdk/page-mod").PageMod({
include:["*", "file://*"],
contentScriptFile: [
"./content/content.js",
],
attachTo: ["existing","top", "frame"],...
Upvotes: 6
Views: 1405
Reputation: 3562
There is an option of match_about_blank
in the content script of firefox now:
Upvotes: 1
Reputation: 3044
I want to update an interesting fact that detected by my teammate Wayland:
The funny thing is that it will work if we build the iframe as following:
It's like if we flush by iframe content by calling 'document.write'.
function buildme() {
var iframe = ...;
iframe.contentDocument.open();
iframe.contentDocument.write("<html><body></body></html>");
iframe.contentDocument.close()
var child = iframe.contentDocument.craeteElement("..");
...
iframe.contentDocument.body.appendChild(child);
}
< iframe id = "myframe"
onload = "buildme();" / >
Upvotes: 1
Reputation: 16538
Try this:
require("sdk/page-mod").PageMod({
include:["*", "file://*", "about:blank", "javascript:*"],
contentScriptFile: [
"./content/content.js",
],
attachTo: [[b]"existing","top", "frame"[/b]],...
Upvotes: 0