我知道在SO上有很多类似的问题,但我似乎无法让它发挥作用.
我正在尝试从Chrome扩展程序中获取当前标签的网址.Hoewever,警报(tab.url)返回"Undefined".我在manifest.json中添加了"tabs"到我的权限.有任何想法吗?
<html>
<head>
<script>
chrome.tabs.getSelected(null, function(tab) {
tab = tab.id;
tabUrl = tab.url;
alert(tab.url);
});
</script>
</head>
Run Code Online (Sandbox Code Playgroud)