![](/img/trans.png)
[英]How can I get the description and the url picture for a Google Chrome tab?
[英]How can i get all URL's of a google chrome window
我目前正在開發擴展程序,但目前我迷失了方向。 基本上,我要它做什么,就是“ OneTab”擴展名的種類。
因此,我的第一個問題是,在將偵聽器添加到擴展按鈕並執行功能之后,我想獲取當前窗口的所有url,並將它們存儲在數組中,並在html文件中顯示它們。
所以即時通訊使用此:
chrome.tabs.getSelected(null,function(tab) {
var tablink = tab.url;
console.log(tablink);
});
但它無法正常工作,我不確定該如何一一檢查所有選項卡。
提前致謝。
chrome.tabs.getSelected()僅會為您提供當前標簽。
為了獲取當前窗口中所有標簽的列表,您需要使用chrome.windows API。 此API將返回當前窗口的對象,該對象將具有選項卡對象的列表。
這是示例代碼:
chrome.windows.getCurrent({"populate":true}, function(currentWindow) {
var tabURLs = [];
var tabs = currentWindow.tabs;
for (var i=0; i<tabs.length; i++) {
tabURLs.push(tabs[i].url);
}
console.log(tabURLs);
});
有關詳細信息,請檢查:
http://developer.chrome.com/extensions/windows.html#method-getCurrent
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.