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

前端 未结 9 630
挽巷
挽巷 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条回答
  •  自闭症患者
    2020-12-04 17:00

    You should use chrome.tabs module to manually open the desired link in a new tab. Try using this jQuery snippet in your popup.html:

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

提交回复
热议问题