"警报"使用hotkey附加组件时没有定义firefox?

时间:2016-03-01 02:38:43

标签: javascript firefox-addon-sdk hotkeys

我在这里有以下代码: https://developer.mozilla.org/en-US/Add-ons/SDK/High-Level_APIs/hotkeys

这是我的代码:

var {Hotkey} = require("sdk/hotkeys");

var number =100;

function checkNumber (number) {
    alert(number);
}

var showHotKey = Hotkey({
    combo: "ctrl-shift-o",
    onPress: function() {
        checkNumber(number);
    }
});
var showHotKey = Hotkey({
    combo: "ctrl-Y",
    onPress: function() {
        checkNumber(number);
    }
});

错误日志:

console.error: checkandcall:
JPM [error]   Message: ReferenceError: alert is not defined
  Stack:
    checkNumber@resource://gre/modules/commonjs/toolkit/loader.js -> resource://checkandcall/index.js:10:2
showHotKey<.onPress@resource://gre/modules/commonjs/toolkit/loader.js -> resource://checkandcall/index.js:16:3
onKeypress@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/keyboard/hotkeys.js:102:7
emitOnObject@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:112:9
emit@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/event/core.js:89:38
handleEvent@resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/commonjs/sdk/keyboard/observer.js:53:5

那么这个解决方案是什么? 谢谢高级!

0 个答案:

没有答案