How to change the title of the current tab using the chrome extension

I would like to change the tab title using the extension. I actually got stuck when using

chrome.tabs.get (function (tabs) {...

How to use the above function? is there any other way i can directly change the name?

+5
source share
2 answers

The title is not a tab property, but a page inside a tab. However, setting the page title is certainly possible: one of the mechanisms would be to add the content of the script that produced document.title:

document.title = "My awesome title!"

For more details, see the documentation for the contents of the script: http://code.google.com/chrome/extensions/content_scripts.html

+6
chrome.tabs.query({'active': true, 'windowId': chrome.windows.WINDOW_ID_CURRENT},
   function(tab){
      chrome.tabs.executeScript(tab.id,{code:"document.title = 'My lame title!'"});
   }
);

. , , ....

chrome.tabs.executeScript(tabId,{code:"document.title = 'My lame title!'"});

.. tabId tab.id , .

+4

All Articles