Answer the question
In order to leave comments, you need to log in
How to open and close a tab after a few seconds?
Good afternoon. Due to the undocumented chrome extensions api and incomplete education on subtle JS issues, I can’t open and close the tab after a few seconds after opening it.
I've already tried everything, it doesn't work out, and dug the docks, and Google - not a single normal explanation of what exactly I'm doing wrong.
Of course, before closing it, you need to execute a script on it and talk to it, but I’ll more or less figure it out, but I have no idea how to close it.
Please help!
chrome.tabs.create({active: true, url: "https://facebook.com"});
chrome.tabs.onUpdated.addListener(function (){
chrome.tabs.query({active: true}, function (alltabs){
...
setTimeout(function (){chrome.tabs.remove(alltabs[0].id)}, 3000);
});
});
Answer the question
In order to leave comments, you need to log in
You can close the current tab like this
chrome.tabs.getCurrent(function(tab) {
chrome.tabs.remove(tab.id, function() { });
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question