Get current URL from within a chrome.contextMenus.onClicked listener

前端 未结 4 732
时光取名叫无心
时光取名叫无心 2021-02-06 09:36

I\'m creating my first Chrome extension and I need some help. I I think everything is working except the fact that I can\'t get the current URL of the tab.

var m         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-06 09:54

    chrome.tabs.getCurrent(function(tab){
        alert(tab.url);
    });
    

    OR if you're in a content script,

    alert(document.location.href);
    

提交回复
热议问题