Search code examples
google-chromegoogle-chrome-extension

Chrome extension, focus on the page instead of omnibox after selected tab is updated?


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.


Solution

  • Using chrome.tabs.update(tab.id, {url: url, selected: true}); does the trick for me.