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

前端 未结 9 650
挽巷
挽巷 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:21

    Send tab url to share blog in new tab:

    // popup.js
    chrome.tabs.query({ active: true, currentWindow: true }, function(tabs){        
        var url = tabs[0].url;
        var title = tabs[0].title;
        document.getElementById('linkQZone').onclick = function () {
            var url1 = 'https://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + url + '&title=' + title + '&desc=&summary=&site=';
            chrome.tabs.create({active: true, url: url1});
        };
    
        document.getElementById('linkQQ').onclick = function () {
            var url1 = 'https://connect.qq.com/widget/shareqq/index.html?url=' + url + '&title=' + title + '&desc=&summary=&site=';
            chrome.tabs.create({active: true, url: url1});
        };
    });
    

提交回复
热议问题