【发布时间】:2014-10-20 11:54:14
【问题描述】:
我已在 Chrome、Firefox 和 IE 上成功安装了我的 crossrider 扩展程序(都是最新的),但浏览器按钮(尽管全部启用)仅适用于 Chrome。
后台代码似乎可以工作,因为我可以触发警报。
我的 background.js 看起来像这样:
appAPI.ready(function() {
var popupDims = {
CH: {height: 400, width: 400},
FF: {height: 400, width: 400},
IE: {height: 400, width: 400},
SF: {height: 400, width: 400}
};
if ("CHFFIESF".indexOf(appAPI.platform) !== -1) {
appAPI.browserAction.setPopup({
resourcePath:'popup.html',
height:popupDims[appAPI.platform].height,
width:popupDims[appAPI.platform].width
});
}
else {
alert('This extension is not supported on your browser');
}});
在我的 popup.html 中有一些 javascript:
function crossriderMain($) {
// load libraries
eval(appAPI.resources.get('select2.js'));
$('[as-trigger]').click(function () {
// retrieves the information for the active tab
appAPI.tabs.getActive(function(tabInfo) {
activeUrl = tabInfo.tabUrl;
appAPI.request.get({
url: 'http://...',
onSuccess: function(response, additionalInfo) {
// show message
},
onFailure: function(httpCode) {
console.log('GET:: Request failed. HTTP Code: ' + httpCode);
}
});
});
})
$('[as-project-dropdown]').select2().on('select2-selecting', function (e) {
// some jquery code
});
appAPI.request.get({
url: 'http://...',
onSuccess: function(response, additionalInfo) {
var dataObject = JSON.parse(response);
$.each(dataObject.data, function(key, value) {
$('[as-project-list]').append('some html...');
});
$('[as-companyname]').html(dataObject.company);
},
onFailure: function(httpCode) {
console.log('GET:: Request failed. HTTP Code: ' + httpCode);
}
});}
在我的 Firefox 控制台中,我可以看到我的扩展程序抛出了一个错误:
MyExtension <Warning: document.getElementById(...) is null Function-name: appAPI.request.get User callback>
@Crossrider 支持:我的应用 id 是 65982
【问题讨论】:
标签: javascript google-chrome-extension firefox-addon crossrider