[英]how to get active tab URL using JS?
I am trying to get an active tab URL using js without extension.我正在尝试使用没有扩展名的 js 获得一个活动标签 URL。 is it possible?可能吗? have tried location.host
and location.href
it doesn't set for my case已经尝试过location.host
和location.href
它没有为我的情况设置
Note: I have opened 4 different tabs with my developing tab in my browser.注意:我在浏览器中使用开发选项卡打开了 4 个不同的选项卡。 how can I find currently active tab URL by using js如何使用 js 找到当前活动的选项卡 URL
Will you please try below.请你试试下面。
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
console.log(tabs[0].url);
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.