I created an extension called quickmarks which will open bookmark by keyword at currently selected tab. I am
using omnibox to select the bookmark (chrome.omnibox.onInputEntered),
and chrome.tabs.update API to open bookmark's url in current tab, by
providing the url in updateProperties. However after the tab is
updated, focus still remains in omnibox, which make the user-
experience not as good as I desired. So is there a way to set the
focus to the page, instead of the omnibox.
Btw, I have tried to open a new tab by using chrome.tabs.create. The
page will be focused instead of omnibox, which is my desired
behaviour.
Thanks.
Using chrome.tabs.update(tab.id, {url: url, selected: true}); does the trick for me.
The accepted answer no longer works in Chrome 31. I had hoped it was a simple matter of the selected property being deprecated but the replacement highlighted property did not assign focus to the tab's content either.
I was only able to steal focus from the Omnibox by closing the current tab and then creating a new tab in its place. Here's the code that works in Chrome 31:
chrome.tabs.getSelected(null, function(tab) {
chrome.tabs.remove(tab.id, function() {
chrome.tabs.create({url:url, active:true});
});
});
While this is certainly not ideal, the current tab is closed and a new one opened so fast you barely notice any difference.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With