LoginSignup
4
4

More than 5 years have passed since last update.

How to open a link from popup.html in a new tab.

Last updated at Posted at 2012-02-15

There are two ways to open a new tab that has a URL clicked in popup.html.

Note: Without both of them, even if an user click a link, nothing occurs.

First, add target='_blank' to A tags.

<a href='http://qiita.com/' target='_blank'>Qiita</a>

Second, use chrome.tabs.create. This function can be used without requesting the 'tabs' permission in the manifest.json.

$(function() {
  $('a').click(function() {
    chrome.tabs.create({url: $(this).attr('href')});
    return false;
  });
});

The difference between them is whether the popup window is closed. The former close it and the later keep it opened.

4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4