Wednesday, 15 February 2012

javascript - Open a tab in browser from a Chrome App -


"tabs" and chrome.tabs API since permissions Is not available in the Chrome app, how can I open a tab in the browser with the specified URL?

Try dynamically create a link and call it click .

  function openab (url) {var a = document.createElement ('a'); A.href = url; A.target = '_ blank'; A.click (); }   

You can then call that function like this:

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

Update

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

If you want to emphasize the link to open in Chrome, then window.open

  window.open ('http: // google. Com ');    

No comments:

Post a Comment