Reputation:
I would like to change the title of a tab using extension.Actually i got stuck up at using
chrome.tabs.get(function(tabs){...
How to use the above function? is there another way i can directly change the title?
Upvotes: 11
Views: 14223
Reputation: 8542
chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
function(tab){
chrome.tabs.executeScript(tab.id,{code:"document.title = 'My lame title!'"});
}
);
The above will change the title of the currently selected tab. If you allready know the id of the tab you want to change, then its....
chrome.tabs.executeScript(tabId,{code:"document.title = 'My lame title!'"});
..where tabId contains the tab.id of the tab that you want to change.
Upvotes: 13
Reputation: 5141
The title isn't a property of the tab, but of the page inside the tab. Adjusting a page's title, however, is certainly possible: one mechanism would be to inject a content script that effected document.title
:
document.title = "My awesome title!"
For details, take a look at the content script documentation: http://code.google.com/chrome/extensions/content_scripts.html
Upvotes: 13