Answer the question
In order to leave comments, you need to log in
How to get the URL of the active tab using JavaScript on a button click in a Chrome extension?
If you specify "window.location.href" - it gives the address of the extension, not the open browser tab
document.addEventListener('DOMContentLoaded', function() {
var checkPageButton = document.getElementById('life');
checkPageButton.addEventListener('click', function() {
chrome.tabs.getSelected(null, function(tab) {
var url= ?????
alert(url);
});
}, false);
}, false);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question