简体   繁体   English

使用扩展栏的Chrome扩展程序

[英]Chrome Extension using popup bar

I'm trying to make something similar to the picture below. 我正在尝试制作类似于下图的内容。

http://img696.imageshack.us/img696/8844/testi.jpg http://img696.imageshack.us/img696/8844/testi.jpg

Unfortunately, I can't seem to get it to work within the extension. 不幸的是,我似乎无法在扩展中使用它。 I get an error stating there was "Error loading the document". 我收到一条错误消息,指出“加载文档时出错”。 The screenshot above was done using a locally made html with the iBox javascript. 上面的屏幕截图是使用本地制作的html和iBox javascript完成的。 Is there any other javascript library that would permit me to load my popup html the same way it does with an icon in the bar? 还有其他JavaScript库可以允许我以与在栏中的图标相同的方式加载弹出窗口html吗?

This is how the code was implemented locally to open the popup: 这是在本地实现代码以打开弹出窗口的方式:

document.addEventListener('keydown', function(e){
        if (e.keyCode == 81 && e.altKey && !e.shiftKey && e.ctrlKey) {
            iBox.showURL('search.html');
            }
        }, false);

This is the function in iBox library: 这是iBox库中的函数:

showURL: function(url, title, params) {
        showInit(title, params, function() {
            for (var i=0; i<_pub.plugins.list.length; i++) {
                var plugin = _pub.plugins.list[i];
                if (plugin.match(url)) {
                    active.plugin = plugin;
                    plugin.render(url, active.params);
                    break;
                }}});}

This is the xmlhttp request: 这是xmlhttp请求:

if (window.XMLHttpRequest) { // Mozilla, Safari,...
            http = new XMLHttpRequest();
            if (http.overrideMimeType) {
                // set type accordingly to anticipated content type
                http.overrideMimeType('text/html');
            }
        }

One possibility is that the permissions in manifest.json aren't properly set. 一种可能是manifest.json中的权限未正确设置。 If the extension relies on making XMLHttpRequest, you need to look at this doc . 如果扩展依赖于制作XMLHttpRequest,则需要查看此doc

Of course, if all the dependent files for the iBox "application" are all located in your extension folder, it should be OK. 当然,如果iBox “应用程序”的所有从属文件都位于扩展文件夹中,则应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM