Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/443.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript crossrider扩展安装在所有浏览器上,但仅在chrome中工作_Javascript_Google Chrome Extension_Firefox Addon_Crossrider - Fatal编程技术网

Javascript crossrider扩展安装在所有浏览器上,但仅在chrome中工作

Javascript crossrider扩展安装在所有浏览器上,但仅在chrome中工作,javascript,google-chrome-extension,firefox-addon,crossrider,Javascript,Google Chrome Extension,Firefox Addon,Crossrider,我已经成功地在Chrome、Firefox和IE上安装了my crossrider扩展(都是最新的),但是浏览器按钮(尽管在所有浏览器上都启用)只适用于Chrome 背景代码似乎很有效,因为我可以触发警报 My background.js如下所示: appAPI.ready(function() { var popupDims = { CH: {height: 400, width: 400}, FF: {height: 400, width: 400}, IE: {he

我已经成功地在Chrome、Firefox和IE上安装了my crossrider扩展(都是最新的),但是浏览器按钮(尽管在所有浏览器上都启用)只适用于Chrome

背景代码似乎很有效,因为我可以触发警报

My 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>
MyExtension

@Crossrider支持:我的应用程序id是65982查看您的代码,我可以看到您没有设置浏览器操作的图标。根据,在某些浏览器上,这对于按钮正确初始化是必不可少的。我用你的代码创建了一个扩展,并使用添加了图标,按钮运行良好

因此,从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.setResourceIcon('logo.jpg');
    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');
}});
[披露:我是一名骑手]