Chrome extension; open a link from popup.html in a new tab

前端 未结 9 633
挽巷
挽巷 2020-12-04 16:23

I\'m doing a Chrome extension and I got helped in this post here.

My problem now is how to open a new tab of chrome that has as URL the link I clicked in the

9条回答
  •  -上瘾入骨i
    2020-12-04 17:20

    I had the same problem. Looked like Konrad's solution would worked, but it opened multiple tabs at once. This happened only after first extension install. So I changed it to

    if (e.target.classList.contains("a-link")) {
        chrome.tabs.create({url: $(e.target).attr('href')});
        return false;
    }
    

    and all is working as expected.

提交回复
热议问题