Firefox安装完成后打开一个特定的网址 [英] Opening a specific url when a Firefox addon has been installed
问题描述
var tabs = require( sdk / tabs); exports.main = function(options,callbacks){if(options.loadReason ==='install'){tabs.open(https://www.google.com); }}; exports.onUnload = function(reason){if(reason ==='uninstall'){tabs.open(https://www.google.com);然后我在 main.js
文件( handlers.js
是上述脚本的名称):
require(handlers.js);
但是,此脚本不会执行 - 无论是在安装过程中还是 。我已经尝试了以下链接的帮助,但我似乎无法解决我的问题:
$ b
https://developer.mozilla.org/zh-CN/Add-ons/SDK/Tutorials/Listening_for_load_and_unload
解决方案解决方案是使用package.json重新打包附件,它的工作除了onUnload函数有一个错误和卸载从来没有被称为一个原因,因此我不得不使用禁用作为检查的原因,它的工作!
有关错误的更多信息,请参阅: https: //developer.mozilla.org/en-US/A dd-ons / SDK / Tutorials / Listening_for_load_and_unload
I am using the Firefox SDK to create an add-on. I would like a specific webpage to be open once that add-on is successfully installed. I created a module to attempt to do so:
var tabs = require("sdk/tabs");
exports.main = function (options, callbacks) {
if (options.loadReason === 'install') {
tabs.open("https://www.google.com");
}
};
exports.onUnload = function (reason) {
if (reason === 'uninstall') {
tabs.open("https://www.google.com");
}
};
I then require this script in my main.js
file (handlers.js
is the name of the above script):
require("handlers.js");
However, this script does not execute -- whether during installation or uninstallation. I have tried the following links for help, but I don't seem to be able to solve my issue:
https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Listening_for_load_and_unload
Opening a page after Firefox extension install
解决方案 The solution for this was repackaging the add-on with the package.json and it worked except for the onUnload function which has a bug and uninstall is never called as a reason and as such I had to use "disable" as the reason to check for and it worked!.
For more on the bug refer to: https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Listening_for_load_and_unload
这篇关于Firefox安装完成后打开一个特定的网址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!