Firefox 插件打开包含内容的选项卡,copy/paste 个选项卡 url 将无法完全加载页面
Firefox addon opens tab with content, copy/paste of the tabs url will not load page fully
我有一个插件可以在工具栏上放置一个 ActionButton
。单击 ActionButton
时,下面的代码是 运行.
代码打开一个新标签并提供一些html
和js
,这充当插件的UI。
新标签页的url
为:
resource://jid1-qljswfs6someid-at-jetpack/addon-firefox/data/html/view.html
如果我 copy/paste 将 url
手动放入另一个新选项卡,html
会显示,但不会加载 js
逻辑。有没有办法不用点击 ActionButton
就可以做到这一点?所以我也许可以为插件添加书签,而不是让 ActionButton
占用 space.
代码:
Tabs.open({
url: require("sdk/self").data.url('html/view.html'),
onReady: function onReady(tab) {
worker = tab.attach({
contentScriptFile: [
require("sdk/self").data.url.get('lib/lib1.js'),
require("sdk/self").data.url.get('js/lib1.js')
],
onMessage: function(message) {
console.log('stuff done');
}
});
}
});
为了 运行 在加载来自 data.url('html/view.html')
的站点时,您必须使用 page-mod 而不是手动将文档附加到选项卡。
您的包含模式类似于 data.url('html/view.html') + "*"
,因此如果存在对文档的散列或查询,它也会附加到页面。
我有一个插件可以在工具栏上放置一个 ActionButton
。单击 ActionButton
时,下面的代码是 运行.
代码打开一个新标签并提供一些html
和js
,这充当插件的UI。
新标签页的url
为:
resource://jid1-qljswfs6someid-at-jetpack/addon-firefox/data/html/view.html
如果我 copy/paste 将 url
手动放入另一个新选项卡,html
会显示,但不会加载 js
逻辑。有没有办法不用点击 ActionButton
就可以做到这一点?所以我也许可以为插件添加书签,而不是让 ActionButton
占用 space.
代码:
Tabs.open({
url: require("sdk/self").data.url('html/view.html'),
onReady: function onReady(tab) {
worker = tab.attach({
contentScriptFile: [
require("sdk/self").data.url.get('lib/lib1.js'),
require("sdk/self").data.url.get('js/lib1.js')
],
onMessage: function(message) {
console.log('stuff done');
}
});
}
});
为了 运行 在加载来自 data.url('html/view.html')
的站点时,您必须使用 page-mod 而不是手动将文档附加到选项卡。
您的包含模式类似于 data.url('html/view.html') + "*"
,因此如果存在对文档的散列或查询,它也会附加到页面。