Chrome Extension Active Tab And Console.log
This is my first chrome extension and I just want to start with a simple thing: grabbing the url and showing it in console.log(). The problem is when I click that button, nothing i
Solution 1:
Probably the console you're looking in is wrong, as your code seems fine (except for using deprecated getSelected()
, you should switch to query()
)
To access the popup's console, you need to right-click your extension's button and select "Inspect popup".
Solution 2:
Awesome, I seem to have been looking at the wrong console. I changed the code to query below.
document.addEventListener('DOMContentLoaded', function() {
var copyURLButton = document.getElementById('copyUrl');
copyURLButton.addEventListener('click', function() {
chrome.tabs.query({ currentWindow: true, active: true }, function (tabs) {
console.log(tabs[0].url);
});
}, false);
}, false);
Post a Comment for "Chrome Extension Active Tab And Console.log"