Google Chrome扩展程序:captureVisibleTab问题 [英] Google Chrome Extension: captureVisibleTab problem

查看:924
本文介绍了Google Chrome扩展程序:captureVisibleTab问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图捕获当前的可见标签,但是我收到未定义的标签。
当按下分机的图标时,下列代码正在执行。当警报被调用时,我会看到 undefined 而不是URL。

  chrome.browserAction.onClicked。 addListener(function(tab){
chrome.windows.getCurrent(function(win){
chrome.tabs.captureVisibleTab(win.id,{format:png},function(imgUrl) {
alert(imgUrl);
});
});
});

我应该怎么做才能获取捕获图片的网址?
有人可以帮我解决这个问题。



谢谢!

解决方案 div>

我猜你的代码来自Chrome扩展站点上给出的例子,是的,它是错误的。



更改manifest.json中的权限属性至此:

 permissions:[
标签
,< all_urls>
]

干杯,
David


I'm trying to capture the current visible tab but I'm receiving undefined. The following code is executing when the extension's icon is pressed. When the alert is called I see undefined instead of an URL.

chrome.browserAction.onClicked.addListener(function(tab) {            
  chrome.windows.getCurrent(function (win) {    
      chrome.tabs.captureVisibleTab(win.id,{"format":"png"}, function(imgUrl) {
            alert(imgUrl);                                            
      });    
  });    
});

What should I do to get the URL of the captured image? Can someone please help me out with this.

Thanks!

解决方案

I guess your code is taken from the example given on the Chrome Extension Website and yes, it's buggy.

Change the permission attribute inside the manifest.json to this:

"permissions": [
    "tabs"
    ,"<all_urls>"
]

Cheers, David

这篇关于Google Chrome扩展程序:captureVisibleTab问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆