我在我的 chrome 扩展程序的 background.js 中有以下函数来获取当前选项卡的 url:
function getCurrentUrl() {
chrome.tabs.query({currentWindow: true, active: true}, function(tabs) {
var tab = tabs[0]
var keys = []
for(var key in tab) keys.push(key + '-' + tab[key])
alert(keys.join(', '))
})
}
但是,警报对话框向我显示:
active-true, height-456, highlighted-true, id-301, incognito-false, index-6, pinned-false, selected-true, status-complete, width-717, windowId-262
'tab' 对象似乎没有 url 属性,正如其他答案所建议的那样。我做错了什么?
最佳答案
关于javascript - 谷歌浏览器 : can't get current tab's url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21013247/