I'm trying to write a Chrome extension that will take the URL of the page the user is on and send it to a server for a response back.
So far I have been trying to use chrome.tabs.getCurrent()
, but I get uncaught TypeError on the getCurrent object.
Is there an easy way for doing this?
I'm trying to write a Chrome extension that will take the URL of the page the user is on and send it to a server for a response back.
So far I have been trying to use chrome.tabs.getCurrent()
, but I get uncaught TypeError on the getCurrent object.
Is there an easy way for doing this?
Share Improve this question edited May 1, 2012 at 17:55 Patrick McElhaney 59.4k41 gold badges137 silver badges170 bronze badges asked Aug 7, 2010 at 10:30 HatchiNZHatchiNZ 431 silver badge4 bronze badges3 Answers
Reset to default 3Any reason why you don't want to use getSelected()
?
chrome.tabs.getSelected(windowId, function(tab) {
alert("current:"+tab.url);
});
getSelected is deprecated. The preferred way to access the current tab is:
chrome.tabs.query({active: true}, function(tab) {
// Do stuff here
}
You are getting the error because getCurrent returns the tab the script is running on, not the tab that is currently selected.
You should probably be using getSelected as noted by serg
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745378373a4625107.html
评论列表(0条)