Open the tab in the browser from the Chrome app.

Since the "tabs" and chrome.tabs APIs are not available in Chrome applications, how can I open a tab in the browser with the specified URL?

+4
source share
3 answers

Try dynamically creating the link and call its click method.

 function openTab(url) { var a = document.createElement('a'); a.href = url; a.target='_blank'; a.click(); } 

Then you can call this function as follows:

 openTab('http://google.com'); 

Update

The previous example opens the link in the default browser (which may be something other than Chrome)

If you want to force the link to open in chrome, use window.open

 window.open('http://google.com'); 
+5
source

In your manifest file, add "browser" to your permissions:

 "permissions": ["browser", ...], 

Then in your js file, call the chrome.browser.openTab function to open the link in Chrome.

  chrome.browser.openTab({ url: "your_url" }); 
+1
source

Now chrome.browser.openTab which should do what you want

0
source

Source: https://habr.com/ru/post/1487608/


All Articles